[Issue 23336] New: cannot take const struct member address at CTFE
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Sep 15 11:32:32 UTC 2022
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 at puremagic.com
Reporter: dkorpel at 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`
--
More information about the Digitalmars-d-bugs
mailing list