https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71391
Bug ID: 71391 Summary: error on aggregate initialization with side-effects in a constexpr function Product: gcc Version: 7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- 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 (); ^