This does not compile:
```
struct Base {
union {
int overlap;
immutable(Sub)* sub;
}
this(Sub) {
sub = new Sub;
}
}
struct Sub {
Base base;
}
immutable c0 = Base(Sub.init);
```
Error: cannot use non-constant CTFE pointer in an initializer Base(, &Sub0(Base(0, __void)))
If you swap the order of the `overlap` and `sub` field, it compiles.
If you change the field in `Sub` to be of a different type than `Base`, it compiles too.
The exact limitations of CTFE and pointers to the data segment are not clear to me, but the above behavior is inconsistent and unclear.
Comment #1 by dlang-bot — 2020-03-09T23:08:13Z
@dkorpel created dlang/dmd pull request #10882 "Fix issue 20603 - 'cannot use non-constant CTFE pointer in an initializer' in recursive structure with overlap" fixing this issue:
- fix issue 20603
https://github.com/dlang/dmd/pull/10882
Comment #2 by dlang-bot — 2022-04-05T08:28:31Z
dlang/dmd pull request #10882 "Fix issue 20603 - 'cannot use non-constant CTFE pointer in an initializer' in recursive structure with overlap" was merged into master:
- ee44aa8da03b0dbc85e092932e3c9198a8e0a19b by dkorpel:
fix issue 20603
https://github.com/dlang/dmd/pull/10882