https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69509

            Bug ID: 69509
           Summary: infinite loop compiling a VLA in a recursive 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: ---

Current GCC trunk (6.0) as well as 5.1.0 loops indefinitely compiling the
following quasi-legal C++ 11 code (loosely based on bug 69496).  Clang rejects
the code because it doesn't accept initialized VLAs.

The same code compiles successfully with -Dconstexpr=''.

$ (cat t.c && ulimit -t 10 && /home/msebor/build/gcc-trunk-svn/gcc/xgcc
-B/home/msebor/build/gcc-trunk-svn/gcc -S -Wall -Wextra -Wpedantic -std=c++14
-xc++ t.c)
constexpr int foo (int n)
{
    int a [n] = { 0 };

    int z = a [0] + (n ? foo (n - 1) : 0);

    return z;
}

constexpr int i = foo (3);
t.c: In function ‘constexpr int foo(int)’:
t.c:3:13: warning: ISO C++ forbids variable length array ‘a’ [-Wvla]
     int a [n] = { 0 };
             ^
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.

Reply via email to