Untyped string variable fails silently. No compiler warning given.
Gary Willoughby
dev at nomad.so
Thu Mar 13 06:57:48 PDT 2014
Rather nasty bug that silently fails. Linux DMD64 D Compiler
v2.065
import std.stdio;
import std.array;
import std.conv;
import std.digest.crc;
import std.random;
class Foo
{
public string generateHash()
{
// The following variable is untyped
// yet no compiler error is thrown.
text = Random(unpredictableSeed).front.to!(string);
// text is null here.
return hexDigest!(CRC32)(text).array.to!(string);
}
}
void main(string[] args)
{
auto foo = new Foo();
writefln("%s", foo.generateHash());
}
Reported: https://d.puremagic.com/issues/show_bug.cgi?id=12357
More information about the Digitalmars-d
mailing list