This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/14160] New: Mangled names for anonymous namespace members not guaranteeed unique
- From: "gcc-bugs at metafoo dot co dot uk" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 16 Feb 2004 15:29:30 -0000
- Subject: [Bug c++/14160] New: Mangled names for anonymous namespace members not guaranteeed unique
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
I have two source files:
main.cpp:
int main(){return 0;}
test.cpp:
namespace { void function() {} }
I run the following commands:
$ g++ -c -o main.o main.cpp
$ g++ -c -o test1.o test.cpp
$ g++ -c -o test2.o test.cpp
$ g++ main.o test1.o test2.o
test2.o(.text+0x0): In function `(anonymous namespace)::function()':
: multiple definition of `(anonymous namespace)::function()'
test1.o(.text+0x0): first defined here
collect2: ld returned 1 exit status
The anonymous namespaces used in creating test1.o and test2.o are guaranteed
by the C++ standard to be distinct and unique. So this program should link.
I can see three solutions: shove a GUID into the anon namespace name, teach
the linker to ignore anon namespace names, or don't emit the names at all
(which decreases link times - and g++ is still a conforming implementation by
the as-if rule).
Richard
--
Summary: Mangled names for anonymous namespace members not
guaranteeed unique
Product: gcc
Version: 3.2.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: gcc-bugs at metafoo dot co dot uk
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14160