digitalmars.D.learn - can not take const struct member address at CTFE , is this a bug?
- test123 (22/22) Sep 13 2022 ```d
- Ruby The Roobster (3/25) Sep 13 2022 The addresses of items stored in memory are by definition not
- test123 (10/12) Sep 13 2022 If so why this can work ?
- Steven Schveighoffer (3/16) Sep 14 2022 Yes, this looks like a bug. Please report if not reported already.
```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 ```
Sep 13 2022
On Tuesday, 13 September 2022 at 11:16:55 UTC, test123 wrote:```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 ```The addresses of items stored in memory are by definition not constant. This isn't a bug.
Sep 13 2022
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`
Sep 13 2022
On 9/14/22 12:53 AM, test123 wrote:On Wednesday, 14 September 2022 at 00:40:38 UTC, Ruby The Roobster wrote:Yes, this looks like a bug. Please report if not reported already. -SteveThe 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`
Sep 14 2022
On Wednesday, 14 September 2022 at 14:41:38 UTC, Steven Schveighoffer wrote:On 9/14/22 12:53 AM, test123 wrote:Thanks for explain. Some how I can not create account for d Bugs, I hope we have use github bugs. Please help me create a bug report if who has free time and bugs account.On Wednesday, 14 September 2022 at 00:40:38 UTC, Ruby The Roobster wrote:Yes, this looks like a bug. Please report if not reported already. -SteveThe 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`
Sep 14 2022
On Thursday, 15 September 2022 at 04:13:56 UTC, test123 wrote:I hope we have github bugs.It's being worked on.Please help me create a bug report if who has free time and bugs account.Here you go: https://issues.dlang.org/show_bug.cgi?id=23336
Sep 15 2022
On Thursday, 15 September 2022 at 11:33:43 UTC, Dennis wrote:On Thursday, 15 September 2022 at 04:13:56 UTC, test123 wrote:glad to know we are move into github.I hope we have github bugs.It's being worked on.thanks for the help.Please help me create a bug report if who has free time and bugs account.Here you go: https://issues.dlang.org/show_bug.cgi?id=23336
Sep 15 2022