[Issue 22617] New: CTFE rejects modification of copied static array
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Dec 21 13:18:14 UTC 2021
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 at puremagic.com
Reporter: moonlightsentinel at 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.
--
More information about the Digitalmars-d-bugs
mailing list