David
2012-11-11 05:31:53 UTC
void f() {
return 5;
}
The above will raise errors. But why not this?:
template
return 0;
}
I'm compiling with gcc-4.5.1. Why does it make a difference using templates such that I wouldn't receive errors from doing the same illegal return statement as a non-template function?. The only setback I get is that I can't call the function (i.e f()) without getting:
error: return-statement with a value, in function returning 'void'
But still, what could be the reason that I am able to define a return statement for a void function template?
Here is the code I have:
template
return 0;
}
// pass
int main() {
}
The above code will pass despite a presumably illegal return statement in a function returning void. Why?