https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120798
Bug ID: 120798 Summary: ICE: tree check: expected class 'type', have 'exceptional' (error_mark) in check_bit_cast_type, at cp/constexpr.cc:5035 Product: gcc Version: 16.0 Status: UNCONFIRMED Keywords: ice-on-invalid-code Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: rush102333 at gmail dot com Target Milestone: --- Starts to crash since gcc-11: https://godbolt.org/z/s78PbMv6E Test Input: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ template<typename T, typename F> constexpr T bit_cast (const F &f) noexcept { return __builtin_bit_cast (T, f); } struct S { int s;S self_member; }; constexpr int foo (const S &x) { return x.s; } constexpr int bar () { return foo (bit_cast<S> (0)); } constexpr int x = bar (); static_assert (!x); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Stack Dump(trunk): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <source>:7:20: error: field 'self_member' has incomplete type 'S' 7 | struct S { int s;S self_member; }; | ^~~~~~~~~~~ <source>:7:8: note: definition of 'struct S' is not complete until the closing brace 7 | struct S { int s;S self_member; }; | ^ <source>:10:23: in 'constexpr' expansion of 'bar()' <source>:9:48: in 'constexpr' expansion of 'bit_cast<S, int>(0)' <source>:5:30: internal compiler error: tree check: expected class 'type', have 'exceptional' (error_mark) in check_bit_cast_type, at cp/constexpr.cc:5035 5 | return __builtin_bit_cast (T, f); | ^ 0x2828ff5 diagnostic_context::diagnostic_impl(rich_location*, diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag (*) [1], diagnostic_t) ???:0 0x284a786 internal_error(char const*, ...) ???:0 0x9ebe77 tree_class_check_failed(tree_node const*, tree_code_class, char const*, int, char const*) ???:0 0xb5db29 maybe_constant_value(tree_node*, tree_node*, mce_value) ???:0 0xdf0907 store_init_value(tree_node*, tree_node*, vec<tree_node*, va_gc, vl_embed>**, int) ???:0 0xbdbd4e cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int, cp_decomp*) ???:0 0xd08033 c_parse_file() ???:0 0xe6fb19 c_common_parse_file() ???: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. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~