2

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?

manlio
  • 18,345
  • 14
  • 76
  • 126
Kisu
  • 29
  • 1

0 Answers0