[Issue 15542] pure function with no argument returning different values (with void-initialized static array)
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Nov 24 16:03:18 UTC 2017
https://issues.dlang.org/show_bug.cgi?id=15542
Steven Schveighoffer <schveiguy at yahoo.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |schveiguy at yahoo.com
Resolution|--- |INVALID
--- Comment #6 from Steven Schveighoffer <schveiguy at yahoo.com> ---
(In reply to Jonathan M Davis from comment #5)
> (In reply to ag0aep6g from comment #4)
> > Note that the test code still compiles even when you add `@safe`. Void
> > initialization of value types is considered `@safe`.
>
> Hmmm. I'm inclined to think that that's a bug, but I suppose that it depends
> on what types it lets you void initialize. I guess that if it's just ints
> and floats and whatnot in the struct, then that doesn't actually pose a
> memory safety problem and wouldn't need to be marked @system, but it still
> seems wrong.
That particular case is not a bug. It's perfectly memory safe to look at/use
your own stack frame without initialization, as long as data doesn't contain a
reference.
> Either way, I think that it's pretty clear that you're dealing with
> undefined behavior if you use a void-initialized object before giving it a
> proper value, and I don't see any reason to treat pure as special in that
> regard.
Agree. This is not a bug, just bad code.
--
More information about the Digitalmars-d-bugs
mailing list