Possible Duplicate:
C++0x static_assert and template instantiation
The following code doesn't compile in GCC due to the static_assert
:
#include <ratio>
#include <iostream>
template<typename T>
class A
{
public:
const static T a = 10;
A()
{
static_assert(false, "Can't instantiate this");
}
};
int main()
{
A<int>::a;
return 0;
}
However, the same code compiles in Visual Studio 2012. I only get a compile error if I actually instantiate the class (also, the static_assert is triggered without instantiating the class if I make the class non-templated).
Which compiler is behaving in accordance with the standard? I think it's GCC but I can't see a clear confirmation in the standard.