[Issue 18016] using uninitialized value is considered @safe but has undefined behavior
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Nov 27 13:52:13 UTC 2017
https://issues.dlang.org/show_bug.cgi?id=18016
RazvanN <razvan.nitu1305 at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |razvan.nitu1305 at gmail.com
--- Comment #1 from RazvanN <razvan.nitu1305 at gmail.com> ---
How about letting void initialization be acceptable in @safe code only if the
value is initialized before being used? In the example from the bug report, the
code would error since x is returned before being initialized. But this should
be acceptable @safe code:
int f() @safe
{
int x = void;
do_some_work();
x = 7;
return x;
}
That would imply an AST walker for the current scope to see if x is initialized
anywhere.
--
More information about the Digitalmars-d-bugs
mailing list