http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51385

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-12-02 
10:36:14 UTC ---
Here's a version which isn't a compile-time-hog but demonstrates the
unnecessary instantiation with a static_assert (so needs -std=c++11)


template <unsigned N> struct NTmpl;
template <typename T, typename U, typename V = NTmpl<sizeof(T *)> >
struct PtrConvs {
   enum { bad = 1 };
};

template <typename Target, typename Source>
struct PtrConvs<Target, Source, NTmpl<sizeof (*(Target **)0 = (Source *)0)> >;

template<typename T> struct test { static const bool value = true; };
template<> struct test<short> { static const bool value = false; };

template <typename T>
struct FussyTemplate
{
    static_assert( test<T>::value, "not short" );
};

struct B { };

typedef char chk[1];
typedef char chk[PtrConvs<FussyTemplate<short>, B>::bad];


EFG and Clang compile this happily, without instantiating FussyTemplate<short>

Reply via email to