https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69496
Bug ID: 69496 Summary: [C++ 14] ICE on VLA 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: --- In C++ 14 mode (but not prior) GCC 5 and 6 fail with an ICE on the program below. It's not clear to me whether this is supposed to be accepted by G++. Clang rejects the test case because it doesn't allow VLAs to be initialized in any context, but G++ otherwise silently accepts VLA initialization. $ cat t.c && /home/msebor/build/gcc-trunk-svn/gcc/xgcc -B/home/msebor/build/gcc-trunk-svn/gcc -Wall -Wextra -Wpedantic -xc++ t.c constexpr int foo (int n) { int a [n] = { }; int z = 0; for (unsigned i = 0; i != sizeof (a); ++i) z += a [i]; return z; } constexpr int n = foo (1); t.c: In function ‘constexpr int foo(int)’: t.c:3:13: warning: ISO C++ forbids variable length array ‘a’ [-Wvla] int a [n] = { }; ^ t.c: At global scope: t.c:13:23: in constexpr expansion of ‘foo(1)’ t.c:13:25: internal compiler error: tree check: expected integer_cst, have plus_expr in get_len, at tree.h:5250 constexpr int n = foo (1); ^ 0x13c08a4 tree_check_failed(tree_node const*, char const*, int, char const*, ...) /home/msebor/scm/fsf/gcc-svn/gcc/tree.c:9605 0x7755ef tree_check(tree_node const*, char const*, int, char const*, tree_code) /home/msebor/scm/fsf/gcc-svn/gcc/tree.h:3262 0x79c5f3 wi::extended_tree<192>::get_len() const /home/msebor/scm/fsf/gcc-svn/gcc/tree.h:5250 0x79c454 wi::int_traits<generic_wide_int<wi::extended_tree<192> > >::decompose(long*, unsigned int, generic_wide_int<wi::extended_tree<192> > const&) /home/msebor/scm/fsf/gcc-svn/gcc/wide-int.h:898 0x79c084 wide_int_ref_storage<true>::wide_int_ref_storage<generic_wide_int<wi::extended_tree<192> > >(generic_wide_int<wi::extended_tree<192> > const&, unsigned int) /home/msebor/scm/fsf/gcc-svn/gcc/wide-int.h:945 0x79bcb6 generic_wide_int<wide_int_ref_storage<true> >::generic_wide_int<generic_wide_int<wi::extended_tree<192> > >(generic_wide_int<wi::extended_tree<192> > const&, unsigned int) /home/msebor/scm/fsf/gcc-svn/gcc/wide-int.h:722 0x79b6dc bool wi::lts_p<generic_wide_int<wi::extended_tree<192> >, generic_wide_int<wi::extended_tree<192> > >(generic_wide_int<wi::extended_tree<192> > const&, generic_wide_int<wi::extended_tree<192> > const&) /home/msebor/scm/fsf/gcc-svn/gcc/wide-int.h:1749 0x79b46a tree_int_cst_lt(tree_node const*, tree_node const*) /home/msebor/scm/fsf/gcc-svn/gcc/tree.h:5300 0xa44235 cxx_eval_array_reference /home/msebor/scm/fsf/gcc-svn/gcc/cp/constexpr.c:1858 0xa4aa7e cxx_eval_constant_expression /home/msebor/scm/fsf/gcc-svn/gcc/cp/constexpr.c:3550 0xa434c4 cxx_eval_binary_expression /home/msebor/scm/fsf/gcc-svn/gcc/cp/constexpr.c:1610 0xa4a9a9 cxx_eval_constant_expression /home/msebor/scm/fsf/gcc-svn/gcc/cp/constexpr.c:3527 0xa48693 cxx_eval_store_expression /home/msebor/scm/fsf/gcc-svn/gcc/cp/constexpr.c:2886 0xa4a2b3 cxx_eval_constant_expression /home/msebor/scm/fsf/gcc-svn/gcc/cp/constexpr.c:3356 0xa4aceb cxx_eval_constant_expression /home/msebor/scm/fsf/gcc-svn/gcc/cp/constexpr.c:3615 0xa4a4d6 cxx_eval_constant_expression /home/msebor/scm/fsf/gcc-svn/gcc/cp/constexpr.c:3395 0xa4a4d6 cxx_eval_constant_expression /home/msebor/scm/fsf/gcc-svn/gcc/cp/constexpr.c:3395 0xa48f0d cxx_eval_statement_list /home/msebor/scm/fsf/gcc-svn/gcc/cp/constexpr.c:3071 0xa4903d cxx_eval_loop_expr /home/msebor/scm/fsf/gcc-svn/gcc/cp/constexpr.c:3098 0xa4b57d cxx_eval_constant_expression /home/msebor/scm/fsf/gcc-svn/gcc/cp/constexpr.c:3723 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <http://gcc.gnu.org/bugs.html> for instructions.