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

            Bug ID: 123821
           Summary: ICE in gimple_add_tmp_var, at gimplify.cc:841 with
                    structured binding declared static in constructor or
                    destructor
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nylonhat at gmail dot com
  Target Milestone: ---

Internal compiler error triggered with structured binding declared static in
constructor or destructor. Note that code below only shows the destructor case
but ICE also happens in constructor case. See: https://godbolt.org/z/YafMYca17

struct A {
    int x;
};

struct B {
    ~B(){
        static auto [x] = A{};
    }
};

int main(){
    B b{};
}

<source>: In destructor 'B::~B()':
<source>:7:21: internal compiler error: in gimple_add_tmp_var, at
gimplify.cc:841
    7 |         static auto [x] = A{};
      |                     ^~~
0x2952c98 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
        ???:0
0x29479db internal_error(char const*, ...)
        ???:0
0xb1e562 fancy_abort(char const*, int, char const*)
        ???:0
0x11ecf31 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ???:0
0x11ec3a7 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ???:0
0x11eef4a gimplify_stmt(tree_node**, gimple**)
        ???:0
0x11ec1d0 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ???:0
0x11eef4a gimplify_stmt(tree_node**, gimple**)
        ???:0
0x11ec1d0 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ???:0
0x11ffe30 gimplify_and_add(tree_node*, gimple**)
        ???:0
0xbce3e5 cp_gimplify_expr(tree_node**, gimple**, gimple**)
        ???:0
0x11ea90b gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ???:0
0x12103f6 gimplify_body(tree_node*, bool)
        ???:0
0x12108bc gimplify_function_tree(tree_node*)
        ???:0
0xfc65a7 cgraph_node::analyze()
        ???:0
0xfc9a66 symbol_table::finalize_compilation_unit()
        ???:0
/cefs/71/71e16ce202e95e778874a97a_gcc-trunk-20260125/bin/../libexec/gcc/x86_64-linux-gnu/16.0.1/cc1plus
-quiet -imultiarch x86_64-linux-gnu -iprefix
/cefs/71/71e16ce202e95e778874a97a_gcc-trunk-20260125/bin/../lib/gcc/x86_64-linux-gnu/16.0.1/
-D_GNU_SOURCE <source> -quiet -dumpdir /app/ -dumpbase output.cpp -dumpbase-ext
.cpp -masm=intel -mtune=generic -march=x86-64 -g -std=c++26
-fdiagnostics-color=always -fno-verbose-asm -o /app/output.s
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Compiler returned: 1

Reply via email to