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

            Bug ID: 120898
           Summary: ICE at -O2 calling function with old-style definition
                    taking a VLA parameter
           Product: gcc
           Version: 15.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: stephenheumann at gmail dot com
  Target Milestone: ---

Compiling this with -O2:

```
int foo(a,b)
        int a;
        int b[][a];
{
        return sizeof(b[1]);
}

int main(void) {
        int c[4][4];
        foo(4,c);
}
```

gives the following:

<source>: In function 'foo':
<source>:1:5: warning: old-style function definition [-Wold-style-definition]
    1 | int foo(a,b)
      |     ^~~
during GIMPLE pass: einline
<source>: In function 'main':
<source>:10:9: internal compiler error: in make_ssa_name_fn, at
tree-ssanames.cc:355
   10 |         foo(4,c);
      |         ^~~~~~~~
0x20bd0f5 diagnostic_context::diagnostic_impl(rich_location*,
diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag
(*) [1], diagnostic_t)
        ???:0
0x20ce646 internal_error(char const*, ...)
        ???:0
0x7a56c6 fancy_abort(char const*, int, char const*)
        ???:0
0xe8f0bf copy_tree_body_r(tree_node**, int*, void*)
        ???:0
0x11391b2 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*,
tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*))
        ???:0
0x1139391 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*,
tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*))
        ???:0
0xe8a88b remap_type(tree_node*, copy_body_data*)
        ???:0
0xe8a88b remap_type(tree_node*, copy_body_data*)
        ???:0
0xe97d59 optimize_inline_calls(tree_node*)
        ???:0
0x1f0f07e early_inliner(function*)
        ???:0
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.

(The ICE still appears if an older standard where old-style definitions are
allowed is specified.)

Godbolt link: https://godbolt.org/z/66Ke7fMxo

>From checking different versions on Godbolt, this appears to be a regression in
GCC 14.

Reply via email to