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: [email protected]
Reporter: [email protected]
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();
}
----
--