Bug 23336 – cannot take const struct member address at CTFE

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-09-15T11:32:32Z
Last change time
2024-12-13T19:24:28Z
Assigned to
No Owner
Creator
Dennis
Moved to GitHub: dmd#20148 →

Comments

Comment #0 by dkorpel — 2022-09-15T11:32:32Z
See: https://forum.dlang.org/post/[email protected] It's possible to take the address of a global struct variable and store it in a const variable, but you can't take the address of a struct member: ``` struct S { uint a, b; } __gshared const S d = {3, 4}; __gshared const e0 = &d; // allowed __gshared const e1 = &d.a; // error ``` The error is: cannot use non-constant CTFE pointer in an initializer `&d.a`
Comment #1 by robert.schadek — 2024-12-13T19:24:28Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20148 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB