can not take const struct member address at CTFE , is this a bug?

Steven Schveighoffer schveiguy at gmail.com
Wed Sep 14 14:41:38 UTC 2022


On 9/14/22 12:53 AM, test123 wrote:
> On Wednesday, 14 September 2022 at 00:40:38 UTC, Ruby The Roobster wrote:
>> The addresses of items stored in memory are by definition not 
>> constant.  This isn't a bug.
> 
> If so why this can work ?
> 
> ```d
> struct c { uint a, b;}
> __gshared const c d = { 3, 4};
> __gshared const e = & d;
> ```
> 
> the `e` can get address of `d`, then it should be to get address of `d.a`

Yes, this looks like a bug. Please report if not reported already.

-Steve


More information about the Digitalmars-d-learn mailing list