https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91846
Bug ID: 91846 Summary: [9/10 Regression] ICE in use_thunk, at cp/method.c:316 Product: gcc Version: 10.0 Status: UNCONFIRMED Keywords: error-recovery, ice-on-invalid-code Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: asolokha at gmx dot com Target Milestone: --- g++-10.0.0-alpha20190915 snapshot (r275736) ICEs when compiling the following testcase reduced from test/SemaCXX/constant-expression-cxx2a.cpp from the clang 9.0.0 test suite: struct B { virtual constexpr char f() const { return 'B'; } char b = f(); }; struct C { virtual constexpr char f() const { return 'C'; } B *pba; char c = ((B*)this)->f(); char ba = pba->f(); }; struct D : B, C { char d = ' '; }; template<typename T> struct Covariant2 { virtual const T *f() const; }; template<typename T> struct Covariant3 : Covariant2<T> { constexpr virtual const D *f() const { return nullptr; } }; constexpr Covariant3<C> cc; static_assert(cc.f()->d == 'D'); % g++-10.0.0-alpha20190915 -c wkzgbhd7.cpp wkzgbhd7.cpp: In instantiation of 'constexpr const D* Covariant3<T>::f() const [with T = C]': wkzgbhd7.cpp:29:19: required from here wkzgbhd7.cpp:24:58: internal compiler error: in use_thunk, at cp/method.c:316 24 | constexpr virtual const D *f() const { return nullptr; } | ^ 0x616688 use_thunk(tree_node*, bool) /var/tmp/portage/sys-devel/gcc-10.0.0_alpha20190915/work/gcc-10-20190915/gcc/cp/method.c:316 0xa38119 emit_associated_thunks(tree_node*) /var/tmp/portage/sys-devel/gcc-10.0.0_alpha20190915/work/gcc-10-20190915/gcc/cp/semantics.c:4341 0xa3845b expand_or_defer_fn(tree_node*) /var/tmp/portage/sys-devel/gcc-10.0.0_alpha20190915/work/gcc-10-20190915/gcc/cp/semantics.c:4443 0x9ee958 instantiate_decl(tree_node*, bool, bool) /var/tmp/portage/sys-devel/gcc-10.0.0_alpha20190915/work/gcc-10-20190915/gcc/cp/pt.c:24802 0x8d46bc instantiate_cx_fn_r /var/tmp/portage/sys-devel/gcc-10.0.0_alpha20190915/work/gcc-10-20190915/gcc/cp/constexpr.c:5495 0x123b246 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*)) /var/tmp/portage/sys-devel/gcc-10.0.0_alpha20190915/work/gcc-10-20190915/gcc/tree.c:12259 0x123bab0 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*)) /var/tmp/portage/sys-devel/gcc-10.0.0_alpha20190915/work/gcc-10-20190915/gcc/tree.c:12589 0x123bab0 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*)) /var/tmp/portage/sys-devel/gcc-10.0.0_alpha20190915/work/gcc-10-20190915/gcc/tree.c:12589 0x123e343 walk_tree_without_duplicates_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*)) /var/tmp/portage/sys-devel/gcc-10.0.0_alpha20190915/work/gcc-10-20190915/gcc/tree.c:12615 0x8dfa3f instantiate_constexpr_fns /var/tmp/portage/sys-devel/gcc-10.0.0_alpha20190915/work/gcc-10-20190915/gcc/cp/constexpr.c:5514 0x8dfa3f cxx_eval_outermost_constant_expr /var/tmp/portage/sys-devel/gcc-10.0.0_alpha20190915/work/gcc-10-20190915/gcc/cp/constexpr.c:5576 0x8e3cdd maybe_constant_value(tree_node*, tree_node*, bool) /var/tmp/portage/sys-devel/gcc-10.0.0_alpha20190915/work/gcc-10-20190915/gcc/cp/constexpr.c:5790 0x8f8c85 cp_fully_fold(tree_node*) /var/tmp/portage/sys-devel/gcc-10.0.0_alpha20190915/work/gcc-10-20190915/gcc/cp/cp-gimplify.c:2197 0xa6db26 cp_build_binary_op(op_location_t const&, tree_code, tree_node*, tree_node*, int) /var/tmp/portage/sys-devel/gcc-10.0.0_alpha20190915/work/gcc-10-20190915/gcc/cp/typeck.c:5561 0x8b654e build_new_op_1 /var/tmp/portage/sys-devel/gcc-10.0.0_alpha20190915/work/gcc-10-20190915/gcc/cp/call.c:6231 0x8b6faa build_new_op(op_location_t const&, tree_code, int, tree_node*, tree_node*, tree_node*, tree_node**, int) /var/tmp/portage/sys-devel/gcc-10.0.0_alpha20190915/work/gcc-10-20190915/gcc/cp/call.c:6275 0xa62611 build_x_binary_op(op_location_t const&, tree_code, tree_node*, tree_code, tree_node*, tree_code, tree_node**, int) /var/tmp/portage/sys-devel/gcc-10.0.0_alpha20190915/work/gcc-10-20190915/gcc/cp/typeck.c:4185 0x99e924 cp_parser_binary_expression /var/tmp/portage/sys-devel/gcc-10.0.0_alpha20190915/work/gcc-10-20190915/gcc/cp/parser.c:9645 0x99f689 cp_parser_assignment_expression /var/tmp/portage/sys-devel/gcc-10.0.0_alpha20190915/work/gcc-10-20190915/gcc/cp/parser.c:9780 0x99f0b9 cp_parser_constant_expression /var/tmp/portage/sys-devel/gcc-10.0.0_alpha20190915/work/gcc-10-20190915/gcc/cp/parser.c:10074