[Issue 13471] CTFE glitch when executing std.digest.crc.crc32Of() and checking the result with enforce(). (keyword: uninitialized variable)
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Mon Jan 19 23:47:59 PST 2015
https://issues.dlang.org/show_bug.cgi?id=13471
Kenji Hara <k.hara.pg at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Hardware|x86_64 |All
--- Comment #1 from Kenji Hara <k.hara.pg at gmail.com> ---
Reduced test case. Switch the error messages by -version=check.
enum buggy1 = foo("Hello World!");
ubyte[4] foo(string str)
{
uint _state = uint.max;
ubyte[4] result = nativeToLittleEndian(~_state);
version(check)
{
import std.exception;
enforce(result != (ubyte[4]).init, "this should not be thrown");
}
return result;
}
union EndianSwapper(T)
{
T value;
ubyte[T.sizeof] array;
}
auto nativeToLittleEndian(T)(T val)
{
return nativeToLittleEndianImpl(val);
}
auto nativeToLittleEndianImpl(T)(T val)
{
EndianSwapper!T es = void;
es.value = val;
return es.array;
}
--
More information about the Digitalmars-d-bugs
mailing list