Bug 21104 – certain array operations fail during CTFE when used to initialize a static array

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-08-02T20:55:21Z
Last change time
2024-12-13T19:10:31Z
Keywords
rejects-valid
Assigned to
No Owner
Creator
elpenguino+D
Moved to GitHub: dmd#17976 →

Comments

Comment #0 by elpenguino+D — 2020-08-02T20:55:21Z
Example: ``` enum b = f(); int[4] f() { int[4] x = [1,2,3,4] * [1,2,3,4]; return x; } ``` f() works fine at runtime, but fails during CTFE with `Error: variable x cannot be read at compile time`. Looking at the -vcg-ast output, it becomes clear why: `int[4] x = arrayOp(x[], [1, 2, 3, 4], [1, 2, 3, 4]);`. The presence of x in that statement is illegal.
Comment #1 by robert.schadek — 2024-12-13T19:10:31Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17976 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB