https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69516
Bug ID: 69516 Summary: [5/6 regression] infinite recursion on a VLA with excess initializer elements in constexpr function Product: gcc Version: 6.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: --- GCC gets itself into infinite recursion compiling the following test case derived derived from the one shown in the discussion of a patch for bug 69496 (https://gcc.gnu.org/ml/gcc-patches/2016-01/msg02098.html). See also bug 69509 (which might be the same problem.) The same problem exists in 5.x. 4.9.3 doesn't suffer from it because it doesn't implement the more relaxed C++ 14 constexpr rules and rejects constexpr functions that consist of more than just a return statement. $ (cat t.c && ulimit -t 10 && /home/msebor/build/gcc-trunk-svn/gcc/xgcc -B/home/msebor/build/gcc-trunk-svn/gcc -Wall -Wextra -Wpedantic -std=c++14 -xc++ t.c) constexpr int foo (int n) { int a[n] = { 1, 2, 3, 4, 5, 6 }; int z = 0; for (unsigned i = 0; i < 3; ++i) z += a[i]; return z; } int main () { constexpr int n = foo (3); __builtin_printf ("%d\n", n); } t.c: In function ‘constexpr int foo(int)’: t.c:3:13: warning: ISO C++ forbids variable length array ‘a’ [-Wvla] int a[n] = { 1, 2, 3, 4, 5, 6 }; ^ xgcc: internal compiler error: Killed (program cc1plus) Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions.