https://bugs.llvm.org/show_bug.cgi?id=38651

            Bug ID: 38651
           Summary: Microsoft C++ doesn't consider anonymous namespaces
                    for back-referencing
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangb...@nondot.org
          Reporter: ztur...@google.com
                CC: llvm-bugs@lists.llvm.org, r...@google.com

If you have this code:

// foo.cpp
namespace {
  namespace {
    int X;
  }
}
//

We mangle this as:
?X@?A0xE81D4E31@?A0xE81D4E31@@3HA

while cl mangles this as:
?X@?A0xed6ebf2d@1@3HA

It's fine that the hash values don't match, but it's a bug that we don't store
this hash in the back-reference table.  Consider this example instead:

namespace X { namespace X {
  namespace { namespace {
    namespace Y { namespace Y {
      int Z;
    } }
  } }
} }

Now we mangle this as:
?Z@Y@1?A0xE81D4E31@?A0xE81D4E31@X@2@3HA 

And Microsoft's own undname demangles this as:
int A0xE81D4E31::X::`anonymous namespace'::`anonymous namespace'::Y::Y::Z

which is obviously wrong.  

This example might seem contrived, but you can make it matter in a more
realistic example too:

// 
namespace {
  struct X {};
  X anonFunc(X x, X y);
  template<typename T> void foo(T t);
}

Here, we mangle anonFunc as:
?anonFunc@?A0xE81D4E31@@YA?AUX@?A0xE81D4E31@@U1?A0xE81D4E31@@0@Z

which undname demangles as:
struct `anonymous namespace'::X __cdecl `anonymous namespace'::anonFunc(struct
`anonymous namespace'::A0xE81D4E31,struct `anonymous namespace'::A0xE81D4E31)

(Note both function parameter types are nonsensical).

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to