The attached code fails to compile with: sfinae.cpp: In instantiation of ‘struct A<C>’: sfinae.cpp:14:8: required from here sfinae.cpp:3:5: error: invalid abstract return type ‘C’ T f(); ^ sfinae.cpp:9:8: note: because the following virtual functions are pure within ‘C’: struct C { ^ sfinae.cpp:10:11: note: virtual C::~C() virtual ~C() = 0; I'm not an expert on the C++ standard, but I would expect the partial specialization of B to be excluded by SFINAE rather than getting a compiler error (clang accepts the code). Looking at previous bugs, it seems that #12672 might be related.
Created attachment 33287 [details] Test case Seems I messed up attaching the test the first time :)
For a short piece of code with no external dependencies it's simpler to just paste it into a comment than attach it: template<typename T> struct A { T f(); }; template<typename T, typename Enable=void> struct B {}; template<typename T> struct B<T, typename A<T>::type> {}; struct C { virtual ~C() = 0; }; int main() { B<C>(); } EDG rejects it for the same reason as GCC.
Thanks for looking! Unfortunately I don't have access to EDG. I have dug through the standard and it seems my understanding of SFINAE was (is) a bit lacking and GCC is indeed correct. It seems there's a bug in clang here instead. On 11/08/14 11:12, redi at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62085 > > --- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> --- > For a short piece of code with no external dependencies it's simpler to just > paste it into a comment than attach it: > > template<typename T> > struct A { > T f(); > }; > > template<typename T, typename Enable=void> struct B {}; > template<typename T> struct B<T, typename A<T>::type> {}; > > struct C { > virtual ~C() = 0; > }; > > int main() { > B<C>(); > } > > > EDG rejects it for the same reason as GCC. >
Not a bug. See: https://gcc.gnu.org/ml/gcc/2015-07/msg00148.html