www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19646] New: Initialization of globals not checked for safe

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

          Issue ID: 19646
           Summary: Initialization of globals not checked for  safe
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: bugzilla digitalmars.com

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
}

--
Feb 03 2019