This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/29647] New: undefined references to static const int members


Compilation of the program below produces:
/tmp/cclEBTTX.o(.gnu.linkonce.t._ZN1XC1Eb+0x1a): In function
`X::X[in-charge](bool)':
: undefined reference to `X::a'
/tmp/cclEBTTX.o(.gnu.linkonce.t._ZN1XC1Eb+0x24): In function
`X::X[in-charge](bool)':
: undefined reference to `X::b'
collect2: ld returned 1 exit status

struct X {
    static const int a = 1, b = 2;
    int x;
    X (bool f) : x(f ? a : b) {}
};
X x(true);
int main () {}

Replacing e. g. "a" with "a+0" makes the errors disappear.


-- 
           Summary: undefined references to static const int members
           Product: gcc
           Version: 3.3.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: christian dot heinlein at uni-ulm dot de


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]