When I try to compile following code (using g++ 4.8.4 with -std=c++11) :
#include <algorithm>
class A
{
public:
static const unsigned a = 1;
//static const unsigned a;
};
// const unsigned A::a = 1;
int main()
{
unsigned b = 2;
std::min(/*(unsigned)*/A::a, b);
}
I've got linking error:
undefined reference to
A::a
If I define A::a
outside of class A or cast A::a
to unsigned while executing std::min
problem does not exist.
Is it GCC bug? If not what's the root cause of such behavior?