Recently, I tested some template code on Codepad. Althought the code is correct, GCC is giving me a really strange error. I also tested it on Ideone:
Tested code:
template<int num>
struct count;
template<>
struct count<-1>
{
};
int main()
{
return 0;
}
Here are the results, on Codepad (GCC 4.1.2) and Ideone (GCC 4.3.4) : GCC 4.1.2 outputs:
Line 5: error: 'count' is not a template
while GCC 4.3.4 compiles normally without errors.
Is this really a compiler bug, or is my code not correct (and compile thanks to extensions?)
If I try
with g++ 4.1.2, I don’t have a problem. If I try
with g++ -Wfatal-errors I get
So my guess is that Codepad is forcing a preamble on you which triggers the error.