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(); } ----
@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
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