https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101313
Bug ID: 101313 Summary: [12 regression] ICE: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in count_type_elements, at expr.c:6273 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 test.c struct struct_A { union bar { enum test x; } var; }; struct struct_B { int x; struct struct_A a; }; int foo() { struct struct_A a = {0}; struct struct_B b = {2, a}; } ******************************** $ 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 test.c test.c:7:15: error: field ‘x’ has incomplete type 7 | enum test x; | ^ test.c: In function ‘foo’: test.c:21:19: internal compiler error: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in count_type_elements, at expr.c:6273 21 | struct struct_B b = {2, a}; | ^ 0x7a7886 tree_class_check_failed(tree_node const*, tree_code_class, char const*, int, char const*) ../../gcc-12-20210627/gcc/tree.c:8734 0x6c0d82 tree_class_check(tree_node*, tree_code_class, char const*, int, char const*) ../../gcc-12-20210627/gcc/tree.h:3496 0x6c0d82 count_type_elements ../../gcc-12-20210627/gcc/expr.c:6273 0xaed8c0 count_type_elements ../../gcc-12-20210627/gcc/expr.c:6245 0xaf0c09 categorize_ctor_elements_1 ../../gcc-12-20210627/gcc/expr.c:6426 0xbc651b gimplify_init_constructor ../../gcc-12-20210627/gcc/gimplify.c:4932 0xbd710a gimplify_modify_expr ../../gcc-12-20210627/gcc/gimplify.c:5762 0xbbf26f gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) ../../gcc-12-20210627/gcc/gimplify.c:14210 0xbc2bf6 gimplify_stmt(tree_node**, gimple**) ../../gcc-12-20210627/gcc/gimplify.c:6869 0xbcc38d gimplify_and_add(tree_node*, gimple**) ../../gcc-12-20210627/gcc/gimplify.c:494 0xbcc38d gimplify_decl_expr ../../gcc-12-20210627/gcc/gimplify.c:1831 0xbbf566 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) ../../gcc-12-20210627/gcc/gimplify.c:14407 0xbc2bf6 gimplify_stmt(tree_node**, gimple**) ../../gcc-12-20210627/gcc/gimplify.c:6869 0xbc01e3 gimplify_statement_list ../../gcc-12-20210627/gcc/gimplify.c:1887 0xbc01e3 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) ../../gcc-12-20210627/gcc/gimplify.c:14655 0xbc2bf6 gimplify_stmt(tree_node**, gimple**) ../../gcc-12-20210627/gcc/gimplify.c:6869 0xbc334d gimplify_bind_expr ../../gcc-12-20210627/gcc/gimplify.c:1426 0xbc0eae gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) ../../gcc-12-20210627/gcc/gimplify.c:14411 0xbd8759 gimplify_stmt(tree_node**, gimple**) ../../gcc-12-20210627/gcc/gimplify.c:6869 0xbd8759 gimplify_body(tree_node*, bool) ../../gcc-12-20210627/gcc/gimplify.c:15442 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 test.c test.c:7:15: error: field ‘x’ has incomplete type 7 | enum test x; | ^ test.c:21: confused by earlier errors, bailing out