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

            Bug ID: 125283
           Summary: internal compiler error: in digest_init_r, at
                    cp/typeck2.cc:1445 when using structured binding
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: arsen at gcc dot gnu.org
  Target Milestone: ---

the following example ICEs (reduced from a larger testcase):

  #include <cstddef>
  #include <tuple>

  template <typename...> struct T
  {
    template <size_t>
    void
    get ()
    {}
  };

  namespace std
  {
  template <typename C> struct tuple_size<T<C>>
  {
    static constexpr size_t value = 2;
  };
  template <typename C> struct tuple_element<0, T<C>>
  {
    using type = C;
  };
  }

  void
  crash ()
  {
    []<typename CbTyp>
      { auto [b, ctx] = T<CbTyp> (); }.operator()<void ()> ();
  }

... it seems that the 'void ()' CbTyp argument is essential:

(gdb) up
Downloading 88.59 K source file
/usr/src/debug/sys-devel/gcc-16.1.0/gcc-16.1.0/gcc/cp/typeck2.cc
#1  0x0000555555bfb739 in digest_init_r (type=0x7ffff5282d20, init=<optimized
out>, nested=0, flags=<optimized out>, complain=<optimized out>) at
/usr/src/debug/sys-devel/gcc-16.1.0/gcc-16.1.0/gcc/cp/typeck2.cc:1445           
1445      gcc_assert (code == ARRAY_TYPE
(gdb) p code
$1 = FUNCTION_TYPE
(gdb) 

backtrace and some trees:
(gdb) bt
#0  fancy_abort (file=0x555558cf6550
"/var/tmp/portage/sys-devel/gcc-16.1.0/work/gcc-16.1.0/gcc/cp/typeck2.cc",
line=1445, 
    function=0x555558bfea9f "digest_init_r") at
/usr/src/debug/sys-devel/gcc-16.1.0/gcc-16.1.0/gcc/diagnostics/context.cc:1780
#1  0x0000555555bfb739 in digest_init_r (type=0x7ffff5282d20, init=<optimized
out>, nested=0, flags=<optimized out>, 
    complain=<optimized out>) at
/usr/src/debug/sys-devel/gcc-16.1.0/gcc-16.1.0/gcc/cp/typeck2.cc:1445
#2  0x0000555557b39e13 in digest_init_flags (type=0x7ffff5282d20,
init=0x7ffff5236c08, flags=<optimized out>, complain=3)
    at /usr/src/debug/sys-devel/gcc-16.1.0/gcc-16.1.0/gcc/cp/typeck2.cc:1540
#3  store_init_value (decl=0x7ffff524c7b8, init=0x7ffff5236c08,
cleanups=0x7fffffffabb8, flags=<optimized out>)
    at /usr/src/debug/sys-devel/gcc-16.1.0/gcc-16.1.0/gcc/cp/typeck2.cc:946
#4  0x0000555557b0861d in check_initializer (decl=0x7ffff524c7b8,
init=<optimized out>, flags=<optimized out>, cleanups=0x7fffffffabb8)
    at /usr/src/debug/sys-devel/gcc-16.1.0/gcc-16.1.0/gcc/cp/decl.cc:8661
#5  0x0000555557aef62a in cp_finish_decl(tree_node*, tree_node*, bool,
tree_node*, int, cp_decomp*) [clone .constprop.1] (
    decl=<optimized out>, init=<optimized out>, init@entry=0x7ffff5236c08,
init_const_expr_p=<optimized out>, 
    init_const_expr_p@entry=false, flags=<optimized out>, flags@entry=1,
decomp=decomp@entry=0x0, asmspec_tree=<optimized out>)
    at /usr/src/debug/sys-devel/gcc-16.1.0/gcc-16.1.0/gcc/cp/decl.cc:9931
#6  0x00005555583ef7ca in cp_finish_decomp (decl=<optimized out>,
decomp=<optimized out>, test_p=<optimized out>)
    at /usr/src/debug/sys-devel/gcc-16.1.0/gcc-16.1.0/gcc/cp/decl.cc:11093
#7  0x0000555557af61d7 in cp_finish_decl (decl=<optimized out>, init=<optimized
out>, init_const_expr_p=<optimized out>, 
    asmspec_tree=<optimized out>, flags=<optimized out>, decomp=0x7fffffffaf40)
    at /usr/src/debug/sys-devel/gcc-16.1.0/gcc-16.1.0/gcc/cp/decl.cc:10133
#8  0x0000555558394a07 in tsubst_stmt (t=<optimized out>,
args=args@entry=0x7ffff527e080, complain=complain@entry=3, 
    in_decl=in_decl@entry=0x7ffff5274880) at
/usr/src/debug/sys-devel/gcc-16.1.0/gcc-16.1.0/gcc/cp/pt.cc:19802
#9  0x0000555558394407 in tsubst_stmt (t=0x7ffff5261f30,
args=args@entry=0x7ffff527e080, complain=complain@entry=3, 
    in_decl=in_decl@entry=0x7ffff5274880) at
/usr/src/debug/sys-devel/gcc-16.1.0/gcc-16.1.0/gcc/tree.h:3781
#10 0x0000555558394407 in tsubst_stmt (t=0x7ffff5261f00, args=0x7ffff527e080,
complain=3, in_decl=0x7ffff5274880)
    at /usr/src/debug/sys-devel/gcc-16.1.0/gcc-16.1.0/gcc/tree.h:3781
#11 0x000055555818b1e1 in instantiate_body (pattern=<optimized out>,
args=args@entry=0x7ffff527e080, d=d@entry=0x7ffff5277800, 
    nested_p=false) at
/usr/src/debug/sys-devel/gcc-16.1.0/gcc-16.1.0/gcc/cp/pt.cc:28686
#12 0x0000555558187639 in instantiate_decl(tree_node*, bool, bool) [clone
.constprop.0] (d=0x7ffff5277800, expl_inst_class_mem_p=false, 
    defer_ok=false) at
/usr/src/debug/sys-devel/gcc-16.1.0/gcc-16.1.0/gcc/cp/pt.cc:28979
#13 0x0000555558122a98 in maybe_instantiate_decl (decl=<optimized out>)
    at /usr/src/debug/sys-devel/gcc-16.1.0/gcc-16.1.0/gcc/cp/decl2.cc:6431
#14 0x0000555557c09856 in maybe_instantiate_decl (decl=<optimized out>) at
/usr/src/debug/sys-devel/gcc-16.1.0/gcc-16.1.0/gcc/tree.h:3927
#15 mark_used (complain=3, decl=<optimized out>) at
/usr/src/debug/sys-devel/gcc-16.1.0/gcc-16.1.0/gcc/cp/decl2.cc:6787
#16 0x0000555557c48faa in build_over_call (cand=<optimized out>,
flags=<optimized out>, complain=<optimized out>)
    at /usr/src/debug/sys-devel/gcc-16.1.0/gcc-16.1.0/gcc/cp/call.cc:11029
#17 0x0000555557de8dbf in build_new_method_call (instance=0x7ffff5236b60,
fns=0x7ffff5272c20, args=<optimized out>, 
    conversion_path=<optimized out>, flags=1, fn_p=0x0, complain=3)
    at /usr/src/debug/sys-devel/gcc-16.1.0/gcc-16.1.0/gcc/cp/call.cc:12317
#18 0x0000555557c1172a in finish_call_expr (fn=<optimized out>,
args=0x7fffffffb768, disallow_virtual=false, koenig_p=false, complain=3)
    at /usr/src/debug/sys-devel/gcc-16.1.0/gcc-16.1.0/gcc/cp/semantics.cc:3413
#19 0x0000555557ac63cf in cp_parser_postfix_expression
(parser=parser@entry=0x7ffff7fb80d0, address_p=address_p@entry=false, 
    cast_p=cast_p@entry=false,
member_access_only_p=member_access_only_p@entry=false,
decltype_p=decltype_p@entry=false, pidk_return=0x0)
    at /usr/src/debug/sys-devel/gcc-16.1.0/gcc-16.1.0/gcc/cp/parser.cc:9129
#20 0x0000555557ac33fa in cp_parser_unary_expression
(parser=parser@entry=0x7ffff7fb80d0, pidk=pidk@entry=0x0, 
    address_p=address_p@entry=false, cast_p=cast_p@entry=false,
decltype_p=decltype_p@entry=false)
    at /usr/src/debug/sys-devel/gcc-16.1.0/gcc-16.1.0/gcc/cp/parser.cc:10616
#21 0x0000555557ac26d7 in cp_parser_cast_expression
(parser=parser@entry=0x7ffff7fb80d0, address_p=address_p@entry=false,
cast_p=false, 
    decltype_p=decltype_p@entry=false, pidk=pidk@entry=0x0) at
/usr/src/debug/sys-devel/gcc-16.1.0/gcc-16.1.0/gcc/cp/parser.cc:11531
#22 0x0000555557ac1622 in cp_parser_binary_expression (parser=0x7ffff7fb80d0,
cast_p=<optimized out>, no_toplevel_fold_p=false, 
    decltype_p=false, prec=PREC_NOT_OPERATOR, pidk=0x0) at
/usr/src/debug/sys-devel/gcc-16.1.0/gcc-16.1.0/gcc/cp/parser.cc:11634
#23 0x0000555557ab135a in cp_parser_assignment_expression
(parser=0x7ffff7fb80d0, pidk=<optimized out>, cast_p=<optimized out>, 
    decltype_p=false) at
/usr/src/debug/sys-devel/gcc-16.1.0/gcc-16.1.0/gcc/cp/parser.cc:11987
#24 0x0000555557b21963 in cp_parser_expression (parser=0x7ffff7fb80d0,
pidk=<optimized out>, cast_p=<optimized out>, 
    decltype_p=<optimized out>, warn_comma_p=false) at
/usr/src/debug/sys-devel/gcc-16.1.0/gcc-16.1.0/gcc/cp/parser.cc:12184
#25 0x0000555557b1a0fe in cp_parser_expression_statement
(parser=0x7ffff7fb80d0, in_statement_expr=0x0)
    at /usr/src/debug/sys-devel/gcc-16.1.0/gcc-16.1.0/gcc/cp/parser.cc:14769
#26 0x0000555557b0daa4 in cp_parser_statement (parser=0x7ffff7fb80d0,
in_statement_expr=0x0, in_compound=true, if_p=0x0, chain=0x0, 
    loc_after_labels=0x0) at
/usr/src/debug/sys-devel/gcc-16.1.0/gcc-16.1.0/gcc/cp/parser.cc:14517
#27 0x0000555557b09e75 in cp_parser_statement_seq_opt (parser=0x7ffff7fb80d0,
in_statement_expr=0x0)
    at /usr/src/debug/sys-devel/gcc-16.1.0/gcc-16.1.0/gcc/cp/parser.cc:15032
#28 cp_parser_compound_statement (parser=parser@entry=0x7ffff7fb80d0,
in_statement_expr=in_statement_expr@entry=0x0, 
    bcs_flags=bcs_flags@entry=0, function_body=function_body@entry=true)
    at /usr/src/debug/sys-devel/gcc-16.1.0/gcc-16.1.0/gcc/cp/parser.cc:14879
#29 0x0000555557b053ea in cp_parser_function_body (parser=0x7ffff7fb80d0,
in_function_try_block=false)
    at /usr/src/debug/sys-devel/gcc-16.1.0/gcc-16.1.0/gcc/cp/parser.cc:28880
#30 cp_parser_ctor_initializer_opt_and_function_body (parser=0x7ffff7fb80d0,
in_function_try_block=false)
    at /usr/src/debug/sys-devel/gcc-16.1.0/gcc-16.1.0/gcc/cp/parser.cc:28931
#31 cp_parser_function_definition_after_declarator (parser=0x7ffff7fb80d0,
inline_p=false)
    at /usr/src/debug/sys-devel/gcc-16.1.0/gcc-16.1.0/gcc/cp/parser.cc:36154
#32 0x0000555557a2f9a6 in
cp_parser_function_definition_from_specifiers_and_declarator
(parser=0x7ffff7fb80d0, 
    decl_specifiers=0x7fffffffc490, attributes=0x0, declarator=<optimized out>)
    at /usr/src/debug/sys-devel/gcc-16.1.0/gcc-16.1.0/gcc/cp/parser.cc:36069
#33 cp_parser_init_declarator (parser=0x7ffff7fb80d0, flags=<optimized out>,
decl_specifiers=0x7fffffffc490, checks=0x0, 
    function_definition_allowed_p=true, member_p=false,
declares_class_or_enum=0, function_definition_p=0x7fffffffc44b, 
    maybe_range_for_decl=0x0, init_loc=0x7fffffffc450,
auto_result=0x7fffffffc458)
    at /usr/src/debug/sys-devel/gcc-16.1.0/gcc-16.1.0/gcc/cp/parser.cc:26079
#34 0x0000555557a16a2f in cp_parser_simple_declaration (parser=0x7ffff7fb80d0,
function_definition_allowed_p=true, 
    maybe_range_for_decl=0x0) at
/usr/src/debug/sys-devel/gcc-16.1.0/gcc-16.1.0/gcc/cp/parser.cc:18099
#35 0x0000555557a0f4e4 in cp_parser_declaration (parser=0x7ffff7fb80d0,
prefix_attrs=<optimized out>)
    at /usr/src/debug/sys-devel/gcc-16.1.0/gcc-16.1.0/gcc/cp/parser.cc:17636
#36 0x000055555861e43a in cp_parser_toplevel_declaration
(parser=0x7ffff7fb80d0)
    at /usr/src/debug/sys-devel/gcc-16.1.0/gcc-16.1.0/gcc/cp/parser.cc:17740
#37 cp_parser_translation_unit (parser=0x7ffff7fb80d0) at
/usr/src/debug/sys-devel/gcc-16.1.0/gcc-16.1.0/gcc/cp/parser.cc:5596
#38 c_parse_file () at
/usr/src/debug/sys-devel/gcc-16.1.0/gcc-16.1.0/gcc/cp/parser.cc:57536
#39 0x00005555585e7854 in c_common_parse_file () at
/usr/src/debug/sys-devel/gcc-16.1.0/gcc-16.1.0/gcc/c-family/c-opts.cc:1430
#40 0x00005555585c9beb in compile_file () at
/usr/src/debug/sys-devel/gcc-16.1.0/gcc-16.1.0/gcc/toplev.cc:455
#41 0x00005555585694c1 in do_compile () at
/usr/src/debug/sys-devel/gcc-16.1.0/gcc-16.1.0/gcc/toplev.cc:2229
#42 toplev::main (this=this@entry=0x7fffffffc946, argc=<optimized out>,
argv=<optimized out>)
    at /usr/src/debug/sys-devel/gcc-16.1.0/gcc-16.1.0/gcc/toplev.cc:2393
#43 0x0000555558567dad in main (argc=<optimized out>, argv=<optimized out>)
    at /usr/src/debug/sys-devel/gcc-16.1.0/gcc-16.1.0/gcc/main.cc:39
(gdb) call debug_tree ((tree) 0x7ffff5282d20)
 <function_type 0x7ffff5282d20 type
    type <void_type 0x7ffff6a23f18 void type_6 VOID
        align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7ffff6a23f18
        pointer_to_this <pointer_type 0x7ffff6a2a000>>
    type_6 QI
    size <integer_cst 0x7ffff6a1b3c0 type <integer_type 0x7ffff6a230a8
bitsizetype> constant 8>
    unit-size <integer_cst 0x7ffff6a1b3d8 type <integer_type 0x7ffff6a23000
sizetype> constant 1>
    align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7ffff6a341f8
    arg-types <tree_list 0x7ffff6a16cd0 value <void_type 0x7ffff6a23f18 void>>>
(gdb) call debug_tree ((tree) 0x7ffff5236c08)
 <call_expr 0x7ffff5236c08
    type <void_type 0x7ffff6a23f18 void type_6 VOID
        align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7ffff6a23f18
        pointer_to_this <pointer_type 0x7ffff6a2a000>>
    side-effects
    fn <addr_expr 0x7ffff527ea00
        type <pointer_type 0x7ffff5282738 type <method_type 0x7ffff527f888>
            unsigned DI
            size <integer_cst 0x7ffff6a1b2d0 constant 64>
            unit-size <integer_cst 0x7ffff6a1b2e8 constant 8>
            align:64 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7ffff5282738>
        constant protected
        arg:0 <function_decl 0x7ffff5281600 get type <method_type
0x7ffff527f888>
            addressable used public external autoinline decl_3 QI defer-output
ice.cc:8:3 align:16 warn_if_not_align:0 context <record_type 0x7ffff527f690 T>
            full-name "void T< <template-parameter-1-1> >::get() [with long
unsigned int <anonymous> = 0; <template-parameter-1-1> = {void()}]"
            not-really-extern
            template-info <template_info 0x7ffff527bd20 tree_1 template
<template_decl 0x7ffff5274cc0 get>
                args <tree_vec 0x7ffff527bc58 length:2
                    elt:0 <tree_vec 0x7ffff527e220 length:1 elt:0
<type_argument_pack 0x7ffff527f5e8>>
                    elt:1 <tree_vec 0x7ffff527e920 length:1
                        elt:0 <integer_cst 0x7ffff6a1b5a0 constant 0>>>
               pending_template>
            use_template=1>>
    arg:0 <convert_expr 0x7ffff527e9a0
        type <pointer_type 0x7ffff527f7e0 type <record_type 0x7ffff527f690 T>
            unsigned DI size <integer_cst 0x7ffff6a1b2d0 64> unit-size
<integer_cst 0x7ffff6a1b2e8 8>
            align:64 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7ffff527f7e0>

        arg:0 <non_lvalue_expr 0x7ffff527e8e0 type <reference_type
0x7ffff527ff18>

            arg:0 <nop_expr 0x7ffff527e8c0 type <reference_type 0x7ffff527ff18>

                arg:0 <addr_expr 0x7ffff527e8a0 type <pointer_type
0x7ffff527f7e0>
                    arg:0 <var_decl 0x7ffff524c720 D.25048>>>>>
    ice.cc:28:13 start: ice.cc:28:13 finish: ice.cc:28:13>
(gdb) p debug_tree ((tree) 0x7ffff524c7b8)
 <var_decl 0x7ffff524c7b8 b
    type <function_type 0x7ffff5282d20 type
        type <void_type 0x7ffff6a23f18 void type_6 VOID
            align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7ffff6a23f18
            pointer_to_this <pointer_type 0x7ffff6a2a000>>
        type_6 QI
        size <integer_cst 0x7ffff6a1b3c0 constant 8>
        unit-size <integer_cst 0x7ffff6a1b3d8 constant 1>
        align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7ffff6a341f8
        arg-types <tree_list 0x7ffff6a16cd0 value <void_type 0x7ffff6a23f18
void>>>
    tree_6 decl_1 decl_5 QI ice.cc:28:13 size <integer_cst 0x7ffff6a1b3c0 8>
unit-size <integer_cst 0x7ffff6a1b3d8 1>
    align:8 warn_if_not_align:0 context <function_decl 0x7ffff5277800
operator()> chain <var_decl 0x7ffff524c720 D.25048>>
$7 = void

can't reproduce on 15

Reply via email to