I have found this piece of bogus code (contrived example below):
template <int I, typename T>
struct foo
{
static int bar()
{
return 1;
}
};
template <std::size_t Index, typename T>
struct foo<Index, T*>
{
static int bar()
{
return 2;
}
};
Please note that specialization uses different type (by mistake). Surprisingly it compiles without any errors (or warnings) with both GCC 4.8.1 and Clang 3.4. But what is even more strange for GCC line foo<0, int*>::bar()
results in 1
, but Clang gives 2
. What is going on? Is it still considered as a specialization by the standard?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With