https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94205
--- Comment #2 from Jason Merrill <jason at gcc dot gnu.org> --- C++14 version that goes back to the introduction of C++14 constexpr in GCC 5: struct S { struct A { S *p; constexpr A(S* p): p(p) {} constexpr operator int() { p->a = 5; return 6; } }; int a = A(this); }; constexpr S s = {}; #define SA(X) static_assert((X),#X) SA(s.a == 6);