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

            Bug ID: 101285
           Summary: [12 Regression] ICE: tree check: expected class
                    ‘type’, have ‘exceptional’ (error_mark) in
                    c_safe_arg_type_equiv_p, at c/c-typeck.c:5830
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: anbu1024.me at gmail dot com
  Target Milestone: ---

$ cat 5b.c 

extern char b[1];

void foo(void (*func)(void *), void * z);

static void bar(void * z) 
{
    return z;
}

void baz()
{
    foo( (void (*)(int (*a)[b++])) bar);
}

--------------------------------

$ gcc-sp12 --version
gcc (GCC) 12.0.0 20210627 (experimental)
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

--------------------------------

$ gcc-sp12 5b.c 
5b.c: In function ‘bar’:
5b.c:8:12: warning: ‘return’ with a value, in function returning void
    8 |     return z;
      |            ^
5b.c:6:13: note: declared here
    6 | static void bar(void * z)
      |             ^~~
5b.c: In function ‘baz’:
5b.c:13:30: error: lvalue required as increment operand
   13 |     foo( (void (*)(int (*a)[b++])) bar);
      |                              ^~
5b.c:13:5: internal compiler error: tree check: expected class ‘type’, have
‘exceptional’ (error_mark) in c_safe_arg_type_equiv_p, at c/c-typeck.c:5830
   13 |     foo( (void (*)(int (*a)[b++])) bar);
      |     ^~~
0x7a7886 tree_class_check_failed(tree_node const*, tree_code_class, char
const*, int, char const*)
        ../../gcc-12-20210627/gcc/tree.c:8734
0x663d43 tree_class_check(tree_node*, tree_code_class, char const*, int, char
const*)
        ../../gcc-12-20210627/gcc/tree.h:3496
0x663d43 c_safe_arg_type_equiv_p
        ../../gcc-12-20210627/gcc/c/c-typeck.c:5830
0x8a8c75 c_safe_function_type_cast_p
        ../../gcc-12-20210627/gcc/c/c-typeck.c:5872
0x8a8c75 build_c_cast(unsigned int, tree_node*, tree_node*)
        ../../gcc-12-20210627/gcc/c/c-typeck.c:6079
0x8a9a34 c_cast_expr(unsigned int, c_type_name*, tree_node*)
        ../../gcc-12-20210627/gcc/c/c-typeck.c:6160
0x8cba45 c_parser_cast_expression
        ../../gcc-12-20210627/gcc/c/c-parser.c:8058
0x8cbbac c_parser_binary_expression
        ../../gcc-12-20210627/gcc/c/c-parser.c:7869
0x8cce65 c_parser_conditional_expression
        ../../gcc-12-20210627/gcc/c/c-parser.c:7592
0x8cd4a0 c_parser_expr_no_commas
        ../../gcc-12-20210627/gcc/c/c-parser.c:7507
0x8bf207 c_parser_expr_list
        ../../gcc-12-20210627/gcc/c/c-parser.c:10746
0x8ce66c c_parser_postfix_expression_after_primary
        ../../gcc-12-20210627/gcc/c/c-parser.c:10475
0x8c5d63 c_parser_postfix_expression
        ../../gcc-12-20210627/gcc/c/c-parser.c:10178
0x8ca16a c_parser_unary_expression
        ../../gcc-12-20210627/gcc/c/c-parser.c:8224
0x8cb939 c_parser_cast_expression
        ../../gcc-12-20210627/gcc/c/c-parser.c:8066
0x8cbbac c_parser_binary_expression
        ../../gcc-12-20210627/gcc/c/c-parser.c:7869
0x8cce65 c_parser_conditional_expression
        ../../gcc-12-20210627/gcc/c/c-parser.c:7592
0x8cd4a0 c_parser_expr_no_commas
        ../../gcc-12-20210627/gcc/c/c-parser.c:7507
0x8cd721 c_parser_expression
        ../../gcc-12-20210627/gcc/c/c-parser.c:10641
0x8cde98 c_parser_expression_conv
        ../../gcc-12-20210627/gcc/c/c-parser.c:10680
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

--------------------------------

$ gcc-sp11 --version
gcc (GCC) 11.1.1 20210619
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

--------------------------------

$ gcc-sp11 5b.c 
5b.c: In function ‘bar’:
5b.c:8:12: warning: ‘return’ with a value, in function returning void
    8 |     return z;
      |            ^
5b.c:6:13: note: declared here
    6 | static void bar(void * z)
      |             ^~~
5b.c: In function ‘baz’:
5b.c:13:30: error: lvalue required as increment operand
   13 |     foo( (void (*)(int (*a)[b++])) bar);
      |                              ^~
5b.c:13:5: error: too few arguments to function ‘foo’
   13 |     foo( (void (*)(int (*a)[b++])) bar);
      |     ^~~
5b.c:4:6: note: declared here
    4 | void foo(void (*func)(void *), void * z);
      |      ^~~

Reply via email to