class T
{
    public:
        static const int STATIC_MEMBER_A = 1;
        static const int STATIC_MEMBER_B = 2;
        T(int x);
    private:
        int t;
};
T::T(int x): t(x > 0? STATIC_MEMBER_A: STATIC_MEMBER_B) {}
int main() {}

Error message:

/tmp/cc0UEe2g.o: In function `T::T(int)':
test.cpp:(.text+0x13): undefined reference to `T::STATIC_MEMBER_A'
test.cpp:(.text+0x1e): undefined reference to `T::STATIC_MEMBER_B'
/tmp/cc0UEe2g.o: In function `T::T(int)':
test.cpp:(.text+0x43): undefined reference to `T::STATIC_MEMBER_A'
test.cpp:(.text+0x4e): undefined reference to `T::STATIC_MEMBER_B'
collect2: ld returned 1 exit status

g++ (GCC) 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)


-- 
           Summary: Linker error for static in-class members
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: hoyninge at in dot tum dot de


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35137

Reply via email to