https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105202
Bug ID: 105202 Summary: ICE: defaulted comparison operators for enumerated types segfault Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: falbrechtskirchinger at gmail dot com Target Milestone: --- Versions: g++ (Compiler-Explorer-Build-gcc-45fb78c9c456ace1d914c836d15af38ae345b902-binutils-2.36.1) 12.0.1 20220407 (experimental) g++-12.0.1 (Gentoo 12.0.1 p2, commit d43fbc7d3f7621e1c8f153c1471d2a5cd20bfdc8) 12.0.1 20220201 (experimental) Code: enum class foo {}; bool operator<(foo, foo) = default; Compile with: g++ -std=c++20 Error: ice_defaulted_operator.cpp:2:28: internal compiler error: Segmentation fault 2 | bool operator<(foo, foo) = default; | ^~~~~~~ Stack trace from Compiler Explorer: 0x218e8e9 internal_error(char const*, ...) ???:0 0x146ee90 strip_array_types(tree_node*) ???:0 0xa7c328 cp_type_quals(tree_node const*) ???:0 0xa6d323 cp_build_qualified_type_real(tree_node*, int, int) ???:0 0x8cbf04 defaultable_fn_check(tree_node*) ???:0 0x84c170 cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int) ???:0 0x9870ad c_parse_file() ???:0 0xb196e2 c_common_parse_file() ???:0 Comparison with other compilers: https://godbolt.org/z/qnq5Gnqc5 This obviously shouldn't segfault. Clang seems to give the most reasonable error message.