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

            Bug ID: 123507
           Summary: ICE in gimplify_expr at gimplify.cc with struct
                    definition in template function parameter
           Product: gcc
           Version: 15.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: 522024330006 at smail dot nju.edu.cn
  Target Milestone: ---

To reproduce: https://godbolt.org/z/a7E5eW4K8

The compiler emits the initial error but subsequently crashes with an Internal
Compiler Error (ICE) during the gimplification phase when the illegally defined
struct is instantiated/used in a local scope.

Program:
```c
template <int N>
void foo(struct S { int x[N]; }* p) {}

int main() {
    foo<1>(0);     
    struct S var;   
}
```

Part of the traceback:
```
internal compiler error: in gimplify_expr, at gimplify.cc:20381
    6 |     struct S var;
      |              ^~~
0x5da1dc8 internal_error(char const*, ...)
        /workspace/install/gcc/src/gcc/gcc/diagnostic-global-context.cc:517
0x5d3f858 fancy_abort(char const*, int, char const*)
        /workspace/install/gcc/src/gcc/gcc/diagnostic.cc:1749
0x1f7769e gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        /workspace/install/gcc/src/gcc/gcc/gimplify.cc:20381
0x1f72aae gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        /workspace/install/gcc/src/gcc/gcc/gimplify.cc:19633
0x1f773af gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        /workspace/install/gcc/src/gcc/gcc/gimplify.cc:20351
0x1f78d54 gimplify_expr
        /workspace/install/gcc/src/gcc/gcc/gimplify.cc:20635
0x1f7a0c9 gimplify_one_sizepos(tree_node**, gimple**)
        /workspace/install/gcc/src/gcc/gcc/gimplify.cc:20778
0x1f79153 gimplify_type_sizes(tree_node*, gimple**)
        /workspace/install/gcc/src/gcc/gcc/gimplify.cc:20675
0x1f793e5 gimplify_type_sizes(tree_node*, gimple**)
        /workspace/install/gcc/src/gcc/gcc/gimplify.cc:20687
0x1f79bf7 gimplify_type_sizes(tree_node*, gimple**)
        /workspace/install/gcc/src/gcc/gcc/gimplify.cc:20719
0x1ef10b1 gimplify_decl_expr
        /workspace/install/gcc/src/gcc/gcc/gimplify.cc:2129
0x1f7342c gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        /workspace/install/gcc/src/gcc/gcc/gimplify.cc:19727
0x1f1a2a6 gimplify_stmt(tree_node**, gimple**)
        /workspace/install/gcc/src/gcc/gcc/gimplify.cc:8458
0x1ef2276 gimplify_statement_list
        /workspace/install/gcc/src/gcc/gcc/gimplify.cc:2285
0x1f752e1 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        /workspace/install/gcc/src/gcc/gcc/gimplify.cc:19981
0x1f1a2a6 gimplify_stmt(tree_node**, gimple**)
        /workspace/install/gcc/src/gcc/gcc/gimplify.cc:8458
0x1eee39b gimplify_bind_expr
        /workspace/install/gcc/src/gcc/gcc/gimplify.cc:1680
0x1f73475 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        /workspace/install/gcc/src/gcc/gcc/gimplify.cc:19731
0x1f1a2a6 gimplify_stmt(tree_node**, gimple**)
        /workspace/install/gcc/src/gcc/gcc/gimplify.cc:8458
0x1ef2276 gimplify_statement_list
        /workspace/install/gcc/src/gcc/gcc/gimplify.cc:2285
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.
```

Reply via email to