This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/34094] New: Undefined static data member can acquire a definition anyway
- From: "simon_baldwin at yahoo dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 14 Nov 2007 18:43:08 -0000
- Subject: [Bug c++/34094] New: Undefined static data member can acquire a definition anyway
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The following program should fail to link, since <anonymous>::B::x is declared
but not defined. However, the program compiles, links, and runs with gcc 4.2.1
and with a relatively recent 4.3 snapshot.
This same program fails to build under gcc 4.1 and earlier, icc 8.1, and Comeau
test drive.
struct A {
A(void *) {}
};
namespace {
struct B : public A {
B() : A(&x) {}
static int x; // declared, but never defined
};
}
int main() {
B::x = 0;
}
--
Summary: Undefined static data member can acquire a definition
anyway
Product: gcc
Version: 4.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: simon_baldwin at yahoo dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34094