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

test123 test123 at gmail.com
Tue Sep 13 11:16:55 UTC 2022


```d
     struct c { uint a, b;}
     __gshared const c d = { 3, 4};
     __gshared const e = &d.a;
```

./test.d(4): Error: expression `&c(3u, 4u).a` is not a constant


I need this to work around C struct array member like this:

```c
struct c {
      uint32_t a, b;
      uint32_t[] arr;
}
```

If I can take const object member address as __gshared const, 
then the problem is fixed.


Or if I can force cast the const object pointer into other type, 
will work be able to work this around. (but not work)

```sh
Error: reinterpreting cast from 
`const(validate_KnownRegex_enum_init_type)*` to 
`const(upb_MiniTable_Enum)*` is not supported in CTFE
```





More information about the Digitalmars-d-learn mailing list