https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94537
--- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> ---
We also reject a constexpr version of the testcase:
$ cat testcase.C
struct A { A *p = this-1; int n = p->n; };
constexpr A
foo()
{
return {};
}
constexpr A a[2] = { {nullptr, 5}, foo() };
static_assert(a[1].n == 5);
$ g++ testcase.C
testcase.C:9:40: in ‘constexpr’ expansion of ‘foo()’
testcase.C:9:42: error: ‘*(&*this)->A::p’ is not a constant expression
9 | constexpr A a[2] = { {nullptr, 5}, foo() };
| ^
testcase.C:10:22: error: non-constant condition for static assertion
10 | static_assert(a[1].n == 5);
| ~~~~~~~^~~~