This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/29647] New: undefined references to static const int members
- From: "christian dot heinlein at uni-ulm dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 30 Oct 2006 11:17:16 -0000
- Subject: [Bug c++/29647] New: undefined references to static const int members
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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