digitalmars.D.bugs - [Issue 23336] New: cannot take const struct member address at CTFE
- d-bugmail puremagic.com (27/27) Sep 15 2022 https://issues.dlang.org/show_bug.cgi?id=23336
https://issues.dlang.org/show_bug.cgi?id=23336 Issue ID: 23336 Summary: cannot take const struct member address at CTFE Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: dkorpel live.nl See: https://forum.dlang.org/post/mgbmiwyrhivvbfoaelsx forum.dlang.org 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` --
Sep 15 2022