https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117065
Bug ID: 117065 Summary: ICE: tree check: expected class 'type', have 'exceptional' (error_mark) in type_has_padding_at_level_p, at gimple-fold.cc:4820 Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: iamanonymous.cs at gmail dot com Target Milestone: --- ******************************************************************************* The compiler produces an internal error during tree_to_poly_int64 when compiling the provided code with the specified options. The issue can also be reproduced on Compiler Explorer. ******************************************************************************* OS and Platform: # uname -a Linux ubuntu 4.15.0-213-generic #224-Ubuntu SMP Mon Jun 19 13:30:12 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux ******************************************************************************* # gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/root/gdbtest/gcc/gcc-241009/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../gcc/configure --prefix=/root/gdbtest/gcc/gcc-241009 --enable-languages=c,c++ --disable-multilib --disable-bootstrap Thread model: posix Supported LTO compression algorithms: zlib gcc version 15.0.0 20241009 (experimental) (GCC) ******************************************************************************* Program: # cat bugreport_0_1.c // struct B {int n;}; typedef unsigned long long A; typedef union { struct B s; A a; } U; void f (A x, unsigned int b) { const U y = {.a = x}; } ******************************************************************************* Command Lines: # gcc bugreport_0_1.c -O0 -Wall -Wextra -Wpedantic -Wconversion -Wshadow -Wcast-align -Wstrict-aliasing -Wuninitialized -c bugreport_0_1.c:5:12: error: field ‘s’ has incomplete type 5 | struct B s; | ^ bugreport_0_1.c: In function ‘f’: bugreport_0_1.c:10:11: warning: unused variable ‘y’ [-Wunused-variable] 10 | const U y = {.a = x}; | ^ bugreport_0_1.c:8:27: warning: unused parameter ‘b’ [-Wunused-parameter] 8 | void f (A x, unsigned int b) | ~~~~~~~~~~~~~^ bugreport_0_1.c:10:11: internal compiler error: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in type_has_padding_at_level_p, at gimple-fold.cc:4820 10 | const U y = {.a = x}; | ^ 0x260066e internal_error(char const*, ...) ../../gcc/gcc/diagnostic-global-context.cc:517 0x8ee210 tree_class_check_failed(tree_node const*, tree_code_class, char const*, int, char const*) ../../gcc/gcc/tree.cc:9053 0x8136bb tree_class_check(tree_node*, tree_code_class, char const*, int, char const*) ../../gcc/gcc/tree.h:3788 0x8136bb type_has_padding_at_level_p(tree_node*) ../../gcc/gcc/gimple-fold.cc:4820 0xcc8652 categorize_ctor_elements_1 ../../gcc/gcc/expr.cc:7223 0xdd1767 gimplify_init_constructor ../../gcc/gcc/gimplify.cc:5595 0xdd442c gimplify_modify_expr ../../gcc/gcc/gimplify.cc:6495 0xdbef43 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) ../../gcc/gcc/gimplify.cc:18141 0xdc16e4 gimplify_stmt(tree_node**, gimple**) ../../gcc/gcc/gimplify.cc:7662 0xdd640e gimplify_and_add(tree_node*, gimple**) ../../gcc/gcc/gimplify.cc:516 0xdd640e gimplify_decl_expr ../../gcc/gcc/gimplify.cc:2171 0xdbf26a gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) ../../gcc/gcc/gimplify.cc:18338 0xdc16e4 gimplify_stmt(tree_node**, gimple**) ../../gcc/gcc/gimplify.cc:7662 0xdc2917 gimplify_bind_expr ../../gcc/gcc/gimplify.cc:1649 0xdbf6d3 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) ../../gcc/gcc/gimplify.cc:18342 0xdc919e gimplify_stmt(tree_node**, gimple**) ../../gcc/gcc/gimplify.cc:7662 0xdc919e gimplify_body(tree_node*, bool) ../../gcc/gcc/gimplify.cc:19420 0xdc95e0 gimplify_function_tree(tree_node*) ../../gcc/gcc/gimplify.cc:19621 0xbe6ba7 cgraph_node::analyze() ../../gcc/gcc/cgraphunit.cc:687 0xbe9807 analyze_functions ../../gcc/gcc/cgraphunit.cc:1251 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. ******************************************************************************* Also ICE on trunk, compiler explorer:https://godbolt.org/z/T6azsn9qT *******************************************************************************