https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99132
--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Ah, the reason it only ICEs with -std=c++20 is that C++17 and earlier don't allow virtual functions to be constexpr and therefore potential_constant_expression_1 doesn't let it try to evaluate the expression. And the reason for the ICE is that genericization changed the h parameter from having B<C *> type to B<C *>& as it needs to be passed by invisible reference, and the constexpr code is not prepared to handle that (i.e. be run so late). Thus I think the above patch is the right fix.