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.
Confirmed.
Examining.
Author: mpolacek Date: Fri Jan 29 09:25:14 2016 New Revision: 232969 URL: https://gcc.gnu.org/viewcvs?rev=232969&root=gcc&view=rev Log: PR c++/69509 PR c++/69516 * constexpr.c (cxx_eval_array_reference): Give the "array subscript out of bound" error earlier. * init.c (build_vec_init): Change NE_EXPR into GT_EXPR. Update the commentary. * g++.dg/ext/constexpr-vla2.C: New test. * g++.dg/ext/constexpr-vla3.C: New test. * g++.dg/ubsan/vla-1.C: Remove dg-shouldfail. Added: trunk/gcc/testsuite/g++.dg/ext/constexpr-vla2.C trunk/gcc/testsuite/g++.dg/ext/constexpr-vla3.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/constexpr.c trunk/gcc/cp/init.c trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/g++.dg/ubsan/vla-1.C
Fixed for GCC 6.