[Issue 20658] New: can modify overlapped storage classes in @safe enum function
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Mon Mar  9 23:49:14 UTC 2020
    
    
  
https://issues.dlang.org/show_bug.cgi?id=20658
          Issue ID: 20658
           Summary: can modify overlapped storage classes in @safe enum
                    function
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: safe
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: ag0aep6g at gmail.com
This is correctly rejected:
----
union U
{
    int m;
    immutable int i;
}
U u;
void main() @safe
{
    () @safe { u.m = 13; } ();
}
----
But factor the function literal out into an enum and DMD wrongly accepts it:
----
union U
{
    int m;
    immutable int i;
}
U u;
enum e = () @safe { u.m = 13; }; /* Should be the same error. */
void main() @safe
{
     e();
}
----
--
    
    
More information about the Digitalmars-d-bugs
mailing list