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

            Bug ID: 121100
           Summary: ICE: Segmentation fault at contains_struct_check
           Product: gcc
           Version: 15.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bic60176 at gmail dot com
  Target Milestone: ---

Created attachment 61871
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=61871&action=edit
testcase

Compiler Explorer: https://godbolt.org/z/46MoEsvoz

console:
<source>:2:12: error: parameter 'n' has just a forward declaration
    2 | void f(int n; int (*(*b)(void))[n]) { sizeof(*(*b)(); int n, int n; int
(*(*b)(void))[n]) { sizeof(*(*b)()); }
      |        ~~~~^
<source>: In function 'f':
<source>:2:53: error: expected ')' before ';' token
    2 | void f(int n; int (*(*b)(void))[n]) { sizeof(*(*b)(); int n, int n; int
(*(*b)(void))[n]) { sizeof(*(*b)()); }
      |                                             ~       ^
      |                                                     )
<source>:2:90: error: expected ';' before '{' token
    2 | void f(int n; int (*(*b)(void))[n]) { sizeof(*(*b)(); int n, int n; int
(*(*b)(void))[n]) { sizeof(*(*b)()); }
      |                                                                        
                 ^~
      |                                                                        
                 ;
<source>: In function 'g':
<source>:6:22: error: 'a' undeclared (first use in this function)
    6 | void g(void) { f(1, &a); }
      |                      ^
<source>:6:22: note: each undeclared identifier is reported only once for each
function it appears in
<source>:6:18: error: passing argument 1 of 'f' makes pointer from integer
without a cast [-Wint-conversion]
    6 | void g(void) { f(1, &a); }
      |                  ^
      |                  |
      |                  int
<source>:2:23: note: expected 'int (* (*)(void))[n]' but argument is of type
'int'
    2 | void f(int n; int (*(*b)(void))[n]) { sizeof(*(*b)(); int n, int n; int
(*(*b)(void))[n]) { sizeof(*(*b)()); }
      |               ~~~~~~~~^~~~~~~~~~~~
<source>:6:16: error: too many arguments to function 'f'; expected 1, have 2
    6 | void g(void) { f(1, &a); }
      |                ^    ~~
<source>:2:6: note: declared here
    2 | void f(int n; int (*(*b)(void))[n]) { sizeof(*(*b)(); int n, int n; int
(*(*b)(void))[n]) { sizeof(*(*b)()); }
      |      ^
<source>: In function 'f':
<source>:6:1: error: expected declaration or statement at end of input
    6 | void g(void) { f(1, &a); }
      | ^~~~
<source>:2:6: internal compiler error: Segmentation fault
    2 | void f(int n; int (*(*b)(void))[n]) { sizeof(*(*b)(); int n, int n; int
(*(*b)(void))[n]) { sizeof(*(*b)()); }
      |      ^
0x253d385 diagnostic_context::diagnostic_impl(rich_location*,
diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag
(*) [1], diagnostic_t)
        ???:0
0x255f066 internal_error(char const*, ...)
        ???:0
0xa45707 contains_struct_check(tree_node*, tree_node_structure_enum, char
const*, int, char const*)
        ???:0
0x152b46c 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
0xe26480 walk_gimple_op(gimple*, tree_node* (*)(tree_node**, int*, void*),
walk_stmt_info*)
        ???:0
0xe2679e walk_gimple_stmt(gimple_stmt_iterator*, tree_node*
(*)(gimple_stmt_iterator*, bool*, walk_stmt_info*), tree_node* (*)(tree_node**,
int*, void*), walk_stmt_info*)
        ???:0
0xe269d5 walk_gimple_seq_mod(gimple**, tree_node* (*)(gimple_stmt_iterator*,
bool*, walk_stmt_info*), tree_node* (*)(tree_node**, int*, void*),
walk_stmt_info*)
        ???:0
0xe2685d walk_gimple_stmt(gimple_stmt_iterator*, tree_node*
(*)(gimple_stmt_iterator*, bool*, walk_stmt_info*), tree_node* (*)(tree_node**,
int*, void*), walk_stmt_info*)
        ???:0
0xe269d5 walk_gimple_seq_mod(gimple**, tree_node* (*)(gimple_stmt_iterator*,
bool*, walk_stmt_info*), tree_node* (*)(tree_node**, int*, void*),
walk_stmt_info*)
        ???:0
0x12641b8 lower_nested_functions(tree_node*)
        ???:0
0xc24894 cgraph_node::analyze()
        ???:0
0xc27e31 symbol_table::finalize_compilation_unit()
        ???: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.
Compiler returned: 1

Reply via email to