Thread overview
can not take const struct member address at CTFE , is this a bug?
Sep 13
test123
Sep 14
test123
Sep 15
test123
Sep 15
Dennis
Sep 15
test123
September 13
    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:

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)

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

On Tuesday, 13 September 2022 at 11:16:55 UTC, test123 wrote:

>
    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:

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)

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.

September 14

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 ?

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

September 14

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 ?

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

September 15

On Wednesday, 14 September 2022 at 14:41:38 UTC, Steven Schveighoffer wrote:

>

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 ?

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

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.

September 15

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

September 15

On Thursday, 15 September 2022 at 11:33:43 UTC, Dennis wrote:

>

On Thursday, 15 September 2022 at 04:13:56 UTC, test123 wrote:

>

I hope we have github bugs.

It's being worked on.

glad to know we are move into github.

> >

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

thanks for the help.