https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70556
Bug ID: 70556 Summary: ICE in cxx_eval_vec_init_1 on a ill-formed lambda capture of a VLA in a template 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: --- The following ill-formed snippet causes an ICE with today's trunk of GCC 6.0 and all prior versions. In case someone wonders, I ran into it by accident (by making a typo while writing a test case for a different bug), not by deliberately trying to break things. $ cat t.c && /build/gcc-trunk/gcc/xgcc -B /build/gcc-trunk/gcc -S -Wall -Wextra -Wpedantic -xc++ t.c template <int N> int f (int n) { int x[1][n]; return [x[0]] /* () { return 0; } */; } int i = f<1>(1); t.c: In function ‘int f(int)’: t.c:6:12: error: expected ‘,’ before ‘[’ token return [x[0]] /* () { return 0; } */; ^ t.c:6:12: error: expected identifier before ‘[’ token t.c: In lambda function: t.c:6:39: error: expected ‘{’ before ‘;’ token return [x[0]] /* () { return 0; } */; ^ t.c: In instantiation of ‘int f(int) [with int N = 1]’: t.c:9:15: required from here t.c:4:7: warning: ISO C++ forbids variable length array [-Wvla] int x[1][n]; ^ t.c:6:10: internal compiler error: in tree_to_uhwi, at tree.c:7345 return [x[0]] /* () { return 0; } */; ^ 0x11504c5b tree_to_uhwi(tree_node const*) /src/gcc/trunk/gcc/tree.c:7345 0x106f2157 cxx_eval_vec_init_1 /src/gcc/trunk/gcc/cp/constexpr.c:2469 0x106f242f cxx_eval_vec_init_1 /src/gcc/trunk/gcc/cp/constexpr.c:2521 0x106f29d3 cxx_eval_vec_init /src/gcc/trunk/gcc/cp/constexpr.c:2591 0x106f8ffb cxx_eval_constant_expression /src/gcc/trunk/gcc/cp/constexpr.c:3872 0x106fa4af cxx_eval_outermost_constant_expr /src/gcc/trunk/gcc/cp/constexpr.c:4110 0x106fb2cb maybe_constant_value_1 /src/gcc/trunk/gcc/cp/constexpr.c:4298 0x106fb487 maybe_constant_value(tree_node*, tree_node*) /src/gcc/trunk/gcc/cp/constexpr.c:4322 0x106fb9f3 fold_non_dependent_expr(tree_node*) /src/gcc/trunk/gcc/cp/constexpr.c:4401 0x1046d70b massage_init_elt /src/gcc/trunk/gcc/cp/typeck2.c:1229 0x1046e6f7 process_init_constructor_record /src/gcc/trunk/gcc/cp/typeck2.c:1401 0x1046f66f process_init_constructor /src/gcc/trunk/gcc/cp/typeck2.c:1609 0x1046cdab digest_init_r /src/gcc/trunk/gcc/cp/typeck2.c:1123 0x1046d04b digest_init(tree_node*, tree_node*, int) /src/gcc/trunk/gcc/cp/typeck2.c:1162 0x10601473 finish_compound_literal(tree_node*, tree_node*, int) /src/gcc/trunk/gcc/cp/semantics.c:2732 0x106d7307 build_lambda_object(tree_node*) /src/gcc/trunk/gcc/cp/lambda.c:114 0x104346ef tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) /src/gcc/trunk/gcc/cp/pt.c:17123 0x1042c083 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) /src/gcc/trunk/gcc/cp/pt.c:15802 0x10425f4b tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) /src/gcc/trunk/gcc/cp/pt.c:15114 0x10425e73 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) /src/gcc/trunk/gcc/cp/pt.c:15104 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.