B
bigfaceworm
I had what I thought was proper SFINAE code. Two declarations of a
function, one more general, one more specific. The code compiles just
fine on gcc 3.3, but fails on 3.4 and 3.4.2. What is wrong with my
code?
My understanding was that the second routine would be called because it
is a better match, and the first one would not be instantiated because
there are no matches. Note: my real example involves constructors to a
template class that I only want to be usable when the class is
specialized (and provides a proper implementation).
The error is:
/tmp/specialized.cpp: In function `void f(T)':
/tmp/specialized.cpp:4: error: size of array `a' is negative
The code is:
------------------------------------------------------------------------
template <typename T>
void f(T t)
{
int a[-1];
}
template <>
void f(int *)
{
;
}
int
main()
{
int a;
f(&a);
return 0;
}
function, one more general, one more specific. The code compiles just
fine on gcc 3.3, but fails on 3.4 and 3.4.2. What is wrong with my
code?
My understanding was that the second routine would be called because it
is a better match, and the first one would not be instantiated because
there are no matches. Note: my real example involves constructors to a
template class that I only want to be usable when the class is
specialized (and provides a proper implementation).
The error is:
/tmp/specialized.cpp: In function `void f(T)':
/tmp/specialized.cpp:4: error: size of array `a' is negative
The code is:
------------------------------------------------------------------------
template <typename T>
void f(T t)
{
int a[-1];
}
template <>
void f(int *)
{
;
}
int
main()
{
int a;
f(&a);
return 0;
}