Changed between 20190224 and 20190303 : $ cat z1.cc template <typename T> void foo (int n) { T a[n]; [=]{a;}; } void bar () { foo <double>; } $ g++-10-20190526 -c z1.cc z1.cc: In instantiation of 'void foo(int) [with T = double]': z1.cc:9:15: required from here z1.cc:5:3: internal compiler error: in tree_to_uhwi, at tree.h:4352 5 | [=]{a;}; | ^~~~~~~ 0x617f9c tree_to_uhwi(tree_node const*) ../../gcc/tree.h:4352 0x617f9c cxx_eval_vec_init_1 ../../gcc/cp/constexpr.c:3126 0x610857 cxx_eval_vec_init ../../gcc/cp/constexpr.c:3221 0x610857 cxx_eval_constant_expression ../../gcc/cp/constexpr.c:4946 0x61392e cxx_eval_outermost_constant_expr ../../gcc/cp/constexpr.c:5328 0x61617c maybe_constant_init_1 ../../gcc/cp/constexpr.c:5705 0x73f396 massage_init_elt ../../gcc/cp/typeck2.c:1348 0x73e666 process_init_constructor_record ../../gcc/cp/typeck2.c:1567 0x73e666 process_init_constructor ../../gcc/cp/typeck2.c:1841 0x73e666 digest_init_r ../../gcc/cp/typeck2.c:1239 0x708501 finish_compound_literal(tree_node*, tree_node*, int, fcl_t) ../../gcc/cp/semantics.c:2874 0x6695c4 build_lambda_object(tree_node*) ../../gcc/cp/lambda.c:117 0x6de512 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) ../../gcc/cp/pt.c:19547 0x6e64c9 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) ../../gcc/cp/pt.c:18247 0x6e64c9 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ../../gcc/cp/pt.c:17923 0x6e5467 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ../../gcc/cp/pt.c:17050 0x6e55f1 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ../../gcc/cp/pt.c:17036 0x6e6151 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ../../gcc/cp/pt.c:17330 0x6e4624 instantiate_decl(tree_node*, bool, bool) ../../gcc/cp/pt.c:24760 0x6f987b instantiate_pending_templates(int) ../../gcc/cp/pt.c:24876
Confirmed.
The crash is here: 3126 unsigned HOST_WIDE_INT max = tree_to_uhwi (nelts); (gdb) p nelts $1 = <plus_expr 0x7fffeab40140> (gdb) pge (sizetype) (SAVE_EXPR <(ssizetype) n + -1>) + 1
Looks like missing verify_constant after the get_array_or_vector_nelts call.
A modified variant : $ cat z2.cc template <int ...> void foo (int n) { int a[n]; [a]{}; } void bar () { foo (2); }
GCC 9.2 has been released.
Started with r269292 aka PR86969 fix.
The following fixes the ICE: --- gcc/cp/constexpr.c.jj 2019-11-16 18:13:28.524822284 +0100 +++ gcc/cp/constexpr.c 2019-11-18 19:38:40.032618830 +0100 @@ -39,7 +39,7 @@ along with GCC; see the file COPYING3. static bool verify_constant (tree, bool, bool *, bool *); #define VERIFY_CONSTANT(X) \ do { \ - if (verify_constant ((X), ctx->quiet, non_constant_p, overflow_p)) \ + if (verify_constant ((X), ctx->quiet, non_constant_p, overflow_p)) \ return t; \ } while (0) @@ -3405,7 +3405,11 @@ cxx_eval_vec_init_1 (const constexpr_ctx tree nelts = get_array_or_vector_nelts (ctx, atype, non_constant_p, overflow_p); - unsigned HOST_WIDE_INT max = tree_to_uhwi (nelts); + unsigned HOST_WIDE_INT max; + if (verify_constant (nelts, ctx->quiet, non_constant_p, overflow_p)) + max = 0; + else + max = tree_to_uhwi (nelts); for (i = 0; i < max; ++i) { tree idx = build_int_cst (size_type_node, i); --- gcc/testsuite/g++.dg/cpp0x/pr90659.C.jj 2019-11-18 19:41:14.805308816 +0100 +++ gcc/testsuite/g++.dg/cpp0x/pr90659.C 2019-11-18 19:43:50.630983085 +0100 @@ -0,0 +1,17 @@ +// PR c++/90659 +// { dg-do compile { target c++11 } } +// { dg-options "" } + +template <typename T> +void +foo (int n) +{ + T a[n]; + [=]{ a; }; +} + +void +bar () +{ + foo <double>; +} but the testcase still FAILs with -std=gnu++17/2a with weird errors: /usr/src/gcc/gcc/testsuite/g++.dg/cpp0x/pr90659.C:10:3: error: name '__a' used in a GNU-style designated initializer for an array /usr/src/gcc/gcc/testsuite/g++.dg/cpp0x/pr90659.C:10:3: error: cannot convert 'double*' to 'double' in initialization and e.g. with auto f = [=]{ a; }; instead it still ICEs elsewhere - in check_initializer. Having a VLA return from a lambda isn't the best idea...
GCC 9.3.0 has been released, adjusting target milestone.
GCC 9.4 is being released, retargeting bugs to GCC 9.5.
GCC 9 branch is being closed
GCC 10.4 is being released, retargeting bugs to GCC 10.5.
GCC 10 branch is being closed.
I can't seem to reproduce this any more.
Same as c#13. Removing gcc-14 regression marker.
GCC 11 branch is being closed.
GCC 12 branch is being closed.