digitalmars.D.bugs - [Issue 22617] New: CTFE rejects modification of copied static array
- d-bugmail puremagic.com (29/29) Dec 21 2021 https://issues.dlang.org/show_bug.cgi?id=22617
https://issues.dlang.org/show_bug.cgi?id=22617 Issue ID: 22617 Summary: CTFE rejects modification of copied static array Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: regression Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: moonlightsentinel disroot.org CTFE rejects the assignment to `copy[0]` if `arr` is const/immutable even though the static array was copied! ======================================== int countWins(const uint[2] arr) { uint[2] copy = arr; copy[0] = 0; return 0; } enum force = countWins([4, 8]); ======================================== ctfe_copy.d(4): Error: cannot modify read-only constant `[4u, 8u]` ctfe_copy.d(8): called from here: `countWins([4u, 8u])` ======================================= Introduced by https://github.com/dlang/dmd/pull/4503. --
Dec 21 2021