https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90080
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |DUPLICATE --- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> --- Reduced: struct false_type { static constexpr bool value = false; }; struct true_type { static constexpr bool value = true; }; template<bool, typename = void> struct enable_if { }; template<typename T> struct enable_if<true, T> { using type = T; }; template<typename T> T&& declval(); template<typename T, typename U, typename = U> struct is_static_castable : false_type {}; template<typename T, typename U> struct is_static_castable<T, U, decltype(static_cast<U>(declval<T>()))> : true_type {}; template<typename To, typename From, typename enable_if<is_static_castable<From*, To*>::value, int>::type = 0> To* safePtrCast(From* from) { return static_cast<To*>(from); } template<typename To, typename From, typename enable_if<!is_static_castable<From*, To*>::value, int>::type = 0> To* safePtrCast(From* from) { return dynamic_cast<To*>(from); } struct BarBase{ virtual ~BarBase() = default;}; struct Bar : virtual BarBase{}; Bar* foo(BarBase* b){ return safePtrCast<Bar>(b); } This started to fail with r258824: PR c++/78489 - wrong SFINAE behavior. PR c++/84489 * pt.c (type_unification_real): Don't defer substitution failure. And was fixed on trunk by r269921: PR c++/87748 - substitution failure error with decltype. This issue is similar to PR 87480; in both cases we were doing non-dependent substitution with processing_template_decl set, leading to member access expressions seeming still instantiation-dependent, and therefore decltype not being simplified to its actual type. And as in that PR, the fix is to clear processing_template_decl while substituting a default template argument. * pt.c (most_specialized_partial_spec): Clear processing_template_decl. So this looks like a dup of that PR, which is still present on gcc-8-branch. *** This bug has been marked as a duplicate of bug 87748 ***