https://issues.dlang.org/show_bug.cgi?id=15542

Jonathan M Davis <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]
                   |                            |m

--- Comment #3 from Jonathan M Davis <[email protected]> ---
I would argue that this simply isn't a bug. void initializers are an @system
way to allow you to delay initialization so that you don't default-initialize a
variable and then assign to it again shortly thereafter. You're never supposed
to actually use the value of a void initialized variable any more than it's
advised to use a variable in C/C++ that you didn't initialize and thus is
filled with garbage. The fact that the pure function returns different values
for different calls is simply a result of failing to do your due diligence with
an @system function and make sure that it's actually @safe in spite of the
@system operations that it's doing. You'd have the same problem if you made it
do pointer arithmetic that made it point past the end of a buffer. There are
plenty of other ways to end up pointing to varying things whenever you violate
@safe. There's nothing particularly special about the void initializer in that
regard. You'd basically have to force all pure functions to be @safe if you
wanted to avoid this problem.

--

Reply via email to