Suppose you have the following (ill-formed) program:
struct A
{
A(int, int)
{
}
};
template <typename T>
class B
{
B()
{
if (sizeof (T) == 1)
{
throw A(0); // wrong, A() needs two arguments
}
}
};
int main()
{
return 0;
}
GCC compiles this program without any errors, clang++ refuses it with an error.
- Is it justified to say thats it is not a bug in GCC because the template isnt instantiated?
- What magic does clang do to find this error?
- What does the C++ standard say about those situations?