D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 20658 - can modify overlapped storage classes in @safe enum function
Summary: can modify overlapped storage classes in @safe enum function
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: No Owner
URL:
Keywords: pull, safe
Depends on:
Blocks:
 
Reported: 2020-03-09 23:49 UTC by ag0aep6g
Modified: 2020-03-10 01:21 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description ag0aep6g 2020-03-09 23:49:14 UTC
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();
}
----
Comment 1 Dlang Bot 2020-03-10 00:15:56 UTC
@aG0aep6G created dlang/dmd pull request #10885 "fix issue 20658 - can modify overlapped storage classes in @safe enum…" fixing this issue:

- fix issue 20658 - can modify overlapped storage classes in @safe enum function

https://github.com/dlang/dmd/pull/10885
Comment 2 Dlang Bot 2020-03-10 01:21:28 UTC
dlang/dmd pull request #10885 "fix issue 20658 - can modify overlapped storage classes in @safe enum…" was merged into master:

- e3b5149cd44d885c55769b301c8c5824e6f752fd by aG0aep6G:
  fix issue 20658 - can modify overlapped storage classes in @safe enum function

https://github.com/dlang/dmd/pull/10885