Bug 5479 – Can't take address of struct literal inside array initializer

Status
REOPENED
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D1 (retired)
Platform
Other
OS
Linux
Creation time
2011-01-23T11:35:33Z
Last change time
2024-12-13T17:54:44Z
Keywords
rejects-valid
Assigned to
No Owner
Creator
Aziz Köksal
Moved to GitHub: dmd#18327 →

Comments

Comment #0 by aziz.koeksal — 2011-01-23T11:35:33Z
Test case: struct Identifier { char[] str; } static const Identifier[] list = [ {"someid"}, ]; // Error: non-constant expression &(Identifier("someid")) static const Identifier* Someid = &list[0];
Comment #1 by razvan.nitu1305 — 2021-03-19T07:56:47Z
This compiles successfully in D2.
Comment #2 by ag0aep6g — 2021-03-19T15:15:55Z
(In reply to RazvanN from comment #1) > This compiles successfully in D2. Uh, no it doesn't? DMD v2.096.0 prints: "Error: cannot use non-constant CTFE pointer in an initializer `&[Identifier("someid")][0]`". Reopening.
Comment #3 by razvan.nitu1305 — 2022-08-15T14:07:40Z
(In reply to ag0aep6g from comment #2) > (In reply to RazvanN from comment #1) > > This compiles successfully in D2. > > Uh, no it doesn't? DMD v2.096.0 prints: "Error: cannot use non-constant CTFE > pointer in an initializer `&[Identifier("someid")][0]`". Reopening. Argh, I omitted the last line of the bug report when copy pasting...
Comment #4 by robert.schadek — 2024-12-13T17:54:44Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18327 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB