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

            Bug ID: 117548
           Summary: ICE when redeclaring function with a compatible type
                    involving C23 structure compatibility
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: luigighiron at gmail dot com
  Target Milestone: ---

The following program causes an internal compiler error on GCC 15:

typedef struct A{int q;}A;
void f(A*);
int main(void){
  struct A{int q;};
  void f(struct A*);
}

It seems that this code generates two possible crashes (tested on godbolt,
using the options -std=c2x and the implicit option -g).

Crash 1:
> <source>: In function 'main':
> <source>:5:17: internal compiler error: in comptypes, at c/c-typeck.cc:1429
>     5 |   void f(struct A*);
>       |                 ^
> 0x258a265 diagnostic_context::diagnostic_impl(rich_location*, 
> diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag 
> (*) [1], diagnostic_t)
>       ???:0
> 0x25a0c55 internal_error(char const*, ...)
>       ???:0
> 0x9b0628 fancy_abort(char const*, int, char const*)
>       ???:0
> 0xa01d82 composite_type(tree_node*, tree_node*)
>       ???:0
> 0x9d7511 pushdecl(tree_node*)
>       ???:0
> 0x9ebd41 start_decl(c_declarator*, c_declspecs*, bool, tree_node*, bool, 
> unsigned int*)
>       ???:0
> 0xa6e2fb c_parse_file()
>       ???:0
> 0xaea329 c_common_parse_file()
>       ???:0
Crash 2:
> hash table checking failed: equal operator returns true for a pair of values 
> with a different hash value
> <source>: In function 'main':
> <source>:5:17: internal compiler error: in hashtab_chk_error, at 
> hash-table.cc:137
>     5 |   void f(struct A*);
>       |                 ^
> 0x258a265 diagnostic_context::diagnostic_impl(rich_location*, 
> diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag 
> (*) [1], diagnostic_t)
>       ???:0
> 0x25a0c55 internal_error(char const*, ...)
>       ???:0
> 0x9b0628 fancy_abort(char const*, int, char const*)
>       ???:0
> 0x9b03c1 hashtab_chk_error()
>       ???:0
> 0x9f3a32 hash_table<c_struct_hasher, false, 
> xcallocator>::find_slot_with_hash(tree_node* const&, unsigned int, 
> insert_option)
>       ???:0
> 0x9efb38 finish_struct(unsigned int, tree_node*, tree_node*, tree_node*, 
> c_struct_parse_info*, tree_node**)
>       ???:0
> 0xa01d82 composite_type(tree_node*, tree_node*)
>       ???:0
> 0x9d7511 pushdecl(tree_node*)
>       ???:0
> 0x9ebd41 start_decl(c_declarator*, c_declspecs*, bool, tree_node*, bool, 
> unsigned int*)
>       ???:0
> 0xa6e2fb c_parse_file()
>       ???:0
> 0xaea329 c_common_parse_file()
>       ???:0
Interestingly, it seems that not using the typedef on the second line here
causes the crash to go away.

Reply via email to