All versions of GCC reject the following valid C++ 14 program. (Clang and EDG accept it as expected.) $ cat zzz.cpp && /home/msebor/build/gcc-6-branch/gcc/xgcc -B /home/msebor/build/gcc-6-branch/gcc -S -Wall -Wextra -Wpedantic zzz.cpp struct S { int a, b; }; constexpr S f () { int x = 0; S z = { 0, ++x }; return z; } constexpr S s = f (); static_assert (s.a + 1 == s.b, ""); zzz.cpp:12:1: error: non-constant condition for static assertion static_assert (s.a + 1 == s.b, ""); ^~~~~~~~~~~~~ zzz.cpp:12:1: error: the value of ‘s’ is not usable in a constant expression zzz.cpp:10:13: note: ‘s’ used in its own initializer constexpr S s = f (); ^
This appears to have been fixed in r224381 (gcc 6.0.0): r224381 | jason | 2015-06-11 11:45:01 -0400 (Thu, 11 Jun 2015) | 3 lines PR c++/66450 * constexpr.c (cxx_eval_store_expression): Avoid messing up outer ctx->ctor. *** This bug has been marked as a duplicate of bug 66450 ***