https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99968
Bug ID: 99968 Summary: [11 Regression] ICE on remove_const_t<incomplete enum type> in requires-expression Product: gcc Version: 11.0 Status: UNCONFIRMED Keywords: ice-on-valid-code Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: redi at gcc dot gnu.org Target Milestone: --- template<typename T> struct remove_const { using type = T; }; template<typename T> struct remove_const<const T> { using type = T; }; template<typename T> using remove_const_t = typename remove_const<T>::type; template<typename T> constexpr inline bool is_enum_v = __is_enum(T); template<typename T> struct is_scoped_enum { static constexpr bool value = false; }; template<typename T> requires is_enum_v<T> && requires (remove_const_t<T> t) { t = t; } struct is_scoped_enum<T> { static constexpr bool value = !requires (T t, int i) { i = t; }; }; template<typename T> constexpr inline bool is_scoped_enum_v = is_scoped_enum<T>::value; void f() { enum E { e0 = is_enum_v<E>, e1 = is_scoped_enum_v<E> }; static_assert( e0 ); static_assert( ! e1 ); } Compiled with -std=gnu++20: e.C: In instantiation of 'struct remove_const<f()::E>': e.C:3:28: required by substitution of 'template<class T> using remove_const_t = typename remove_const::type [with T = f()::E]' e.C:15:26: required by substitution of 'template<class T> requires (is_enum_v<T>) && requires(typename remove_const<T>::type t) {t = t;} struct is_scoped_enum<T> [with T = f()::E]' e.C:22:61: required from 'constexpr const bool is_scoped_enum_v<f()::E>' e.C:26:36: required from here e.C:1:29: error: enum value type is not 'INTEGER_TYPE' nor convertible to the enum 1 | template<typename T> struct remove_const { using type = T; }; | ^~~~~~~~~~~~ <const_decl 0x7fcf7f625070 e0 type <boolean_type 0x7fcf7f4c1b28 bool public unsigned type_6 QI size <integer_cst 0x7fcf7f4a3fa8 constant 8> unit-size <integer_cst 0x7fcf7f4a3fc0 constant 1> align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fcf7f4c1b28 precision:1 min <integer_cst 0x7fcf7f4c4210 0> max <integer_cst 0x7fcf7f4c4240 1>> readonly constant VOID e.C:26:12 align:1 warn_if_not_align:0 context <enumeral_type 0x7fcf7f61cf18 E> initial <integer_cst 0x7fcf7f4c4240 1> chain <type_decl 0x7fcf7f61f7b8 E>> <identifier_node 0x7fcf7f61b900 e0 normal local bindings <(nil)>> <enumeral_type 0x7fcf7f61cf18 E type_6 VOID align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fcf7f61cf18 precision:0 values <tree_list 0x7fcf7f61de88 purpose <identifier_node 0x7fcf7f61b900 e0 normal local bindings <(nil)>> value <const_decl 0x7fcf7f625070 e0 type <boolean_type 0x7fcf7f4c1b28 bool> readonly constant VOID e.C:26:12 align:1 warn_if_not_align:0 context <enumeral_type 0x7fcf7f61cf18 E> initial <integer_cst 0x7fcf7f4c4240 1> chain <type_decl 0x7fcf7f61f7b8 E>>> context <function_decl 0x7fcf7f608d00 f> chain <type_decl 0x7fcf7f61f7b8 E>> e.C:1:29: internal compiler error: 'verify_type' failed 0x1385d10 verify_type(tree_node const*) /home/jwakely/src/gcc/gcc/gcc/tree.c:14926 0xcdd13d gen_type_die_with_usage /home/jwakely/src/gcc/gcc/gcc/dwarf2out.c:25731 0xcdeaa6 gen_type_die /home/jwakely/src/gcc/gcc/gcc/dwarf2out.c:25962 0xcdf01c modified_type_die /home/jwakely/src/gcc/gcc/gcc/dwarf2out.c:13727 0xce29f1 add_type_attribute /home/jwakely/src/gcc/gcc/gcc/dwarf2out.c:21910 0xcf78da gen_typedef_die /home/jwakely/src/gcc/gcc/gcc/dwarf2out.c:25638 0xcf78da gen_typedef_die /home/jwakely/src/gcc/gcc/gcc/dwarf2out.c:25572 0xcd9f8a gen_decl_die /home/jwakely/src/gcc/gcc/gcc/dwarf2out.c:26604 0xcdc18d gen_member_die /home/jwakely/src/gcc/gcc/gcc/dwarf2out.c:25415 0xcdc18d gen_struct_or_union_type_die /home/jwakely/src/gcc/gcc/gcc/dwarf2out.c:25511 0xcdc18d gen_tagged_type_die /home/jwakely/src/gcc/gcc/gcc/dwarf2out.c:25712 0xcdd42a gen_tagged_type_die /home/jwakely/src/gcc/gcc/gcc/dwarf2out.c:25666 0xcdd42a gen_type_die_with_usage /home/jwakely/src/gcc/gcc/gcc/dwarf2out.c:25907 0xcdeaa6 gen_type_die /home/jwakely/src/gcc/gcc/gcc/dwarf2out.c:25962 0xcd9a52 gen_decl_die /home/jwakely/src/gcc/gcc/gcc/dwarf2out.c:26601 0xcdac53 dwarf2out_decl /home/jwakely/src/gcc/gcc/gcc/dwarf2out.c:27156 0xcdb1e1 dwarf2out_type_decl /home/jwakely/src/gcc/gcc/gcc/dwarf2out.c:26874 0xcdb1e1 dwarf2out_type_decl /home/jwakely/src/gcc/gcc/gcc/dwarf2out.c:26869 0xfc7994 rest_of_type_compilation(tree_node*, int) /home/jwakely/src/gcc/gcc/gcc/passes.c:339 0x8fdc63 finish_struct_1(tree_node*) /home/jwakely/src/gcc/gcc/gcc/cp/class.c:7548 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.