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++/14160] New: Mangled names for anonymous namespace members not guaranteeed unique


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


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