Shouldn't invalid references like this fail at compile time?
Aedt
aedt at rocketmail.com
Mon Jan 22 23:30:16 UTC 2018
I was asked in Reddit
(https://www.reddit.com/r/learnprogramming/comments/7ru82l/i_was_thinking_of_using_d_haxe_or_another/) how would D handle the following similar D code. I'm surprised that both dmd and ldc provides no warnings even with -w argument passed.
import std.stdio;
void main()
{
string foo = "foo";
string* p1, p2;
string*[] ls;
ls ~= &foo;
p1 = ls[0];
ls.destroy();
p2 = ls[0];
writeln(p2);
}
More information about the Digitalmars-d
mailing list