Consider the following code:
template<int* a>
class base {};
int main()
{
base<(int*)0> test;
return 0;
}
Both Comeau and MSVC compile this without issues (except for Comeau warning about an unused variable), while GCC fails on the base<(int*)0> test;
line, stating
In function `int main()': a casts to a type other than an integral or enumeration type cannot appear in a constant-expression
template argument 1 is invalid
What exactly is it complaining about? And who's right -- should this code compile? It's worth noting that my GCC version is extremely old (3.4.2) so that may have something to do with it. Thanks.