Bug 21446 – Cannot initialize a static array from a struct field of dynamic array type at compile time

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2020-12-02T14:54:47Z
Last change time
2024-12-13T19:13:09Z
Keywords
CTFE, rejects-valid
Assigned to
No Owner
Creator
Max Samukha
Moved to GitHub: dmd#18004 →

Comments

Comment #0 by maxsamukha — 2020-12-02T14:54:47Z
struct S { int[] a; } enum s = S(new int[1]); int[1] a = s.a; void main() { } onlineapp.d(8): Error: cannot cast expression S([0]).a of type int[] to int[1] Compiles if S is constructed directly in the initializer: int[1] a = S(new int[1]).a; // ok
Comment #1 by nick — 2024-11-24T20:21:42Z
Workaround - use `[]`: int[1] a = s.a[];
Comment #2 by robert.schadek — 2024-12-13T19:13:09Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18004 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB