Bug 19646 – Initialization of globals not checked for @safe

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2019-02-04T01:38:40Z
Last change time
2023-02-16T06:05:18Z
Keywords
pull, safe
Assigned to
No Owner
Creator
Walter Bright

Comments

Comment #0 by bugzilla — 2019-02-04T01:38:40Z
Reported by Luís Marques: import std.stdio; @safe: const x = 42; int* y = cast(int*) &x; void main() { *y = 7; writeln(x); // prints 42 }
Comment #1 by dlang-bot — 2019-06-18T09:44:15Z
@WalterBright created dlang/dmd pull request #10056 "fix Issue 19646 - Initialization of globals not checked for @safe" fixing this issue: - fix Issue 19646 - Initialization of globals not checked for @safe https://github.com/dlang/dmd/pull/10056
Comment #2 by dlang-bot — 2019-06-18T20:06:52Z
dlang/dmd pull request #10056 "fix Issue 19646 - Initialization of globals not checked for @safe" was merged into master: - 534383bedd60c72cdad4755d03f26b24b7eae207 by Walter Bright: fix Issue 19646 - Initialization of globals not checked for @safe https://github.com/dlang/dmd/pull/10056
Comment #3 by ag0aep6g — 2019-11-02T09:42:16Z
The exact code from the description doesn't compile anymore. But we just need to change some detail and DMD accepts it again. See issue 20347.
Comment #4 by snarwin+bugzilla — 2023-02-16T06:05:18Z
*** Issue 21664 has been marked as a duplicate of this issue. ***