It appears that 4.2 isn't making anonymous namespace variables unique (it's
also making them global). This is preventing LLVM from compiling with the 4.2
compiler.

$ cat foo.cpp
#include <typeinfo>

namespace {
  class foo {
   virtual void bar();
  };
}

void foo::bar() {}

#ifdef FOO
const std::type_info &X = typeid(foo);
#else
const std::type_info &Y = typeid(foo);
#endif

extern const std::type_info &X;

#ifndef FOO
int main() {}
#endif

$ g++-4.2 foo.cpp -c -o a.o
$ g++-4.2 foo.cpp -c -o b.o -DFOO
$ g++-4.2 a.o b.o
ld64-73.6 failed: duplicate symbol typeinfo for (anonymous namespace)::fooin
b.o and a.o


-- 
           Summary: unwanted anonymous namespacing linkage
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: mrs at apple dot com
GCC target triplet: i686-apple-darwin9


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

Reply via email to