[llvm-bugs] [Bug 34511] New: Mangled names for unnamed local types declared in block expressions in non-static data member initializers lack discriminators

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Sep 6 13:50:31 PDT 2017


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

            Bug ID: 34511
           Summary: Mangled names for unnamed local types declared in
                    block expressions in non-static data member
                    initializers lack discriminators
           Product: clang
           Version: 4.0
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: thonerma at synopsys.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

Mangled names for unnamed local types declared in block expressions in
non-static data member initializers lack discriminators:

$ cat t.cpp
template<typename T> void tf(T) {}
struct S {
  void(^bp)() = ^{
    enum {} e;
    tf(e);
    struct {} s1;
    tf(s1);
    struct {} s2;
    tf(s2);
  };
};
auto x = S{}.bp;

$ clang++ --version
clang version 4.0.0 (tags/RELEASE_400/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix

$ clang++ -c -std=c++11 -fblocks t.cpp
t.cpp:1:27: error: definition with same mangled name as another definition
template<typename T> void tf(T) {}
                          ^
t.cpp:1:27: note: previous definition is here
t.cpp:1:27: error: definition with same mangled name as another definition
template<typename T> void tf(T) {}
                          ^
t.cpp:1:27: note: previous definition is here
2 errors generated.

Reducing the function template from a definition to a declaration reveals the
conflicting name:

$ cat t2.cpp
template<typename T> void tf(T);
struct S {
  void(^bp)() = ^{
    enum {} e;
    tf(e);
    struct {} s1;
    tf(s1);
    struct {} s2;
    tf(s2);
  };
};
auto x = S{}.bp;

$ clang++ -c -std=c++11 -fblocks t2.cpp
$ nm t2.o
                 U _NSConcreteGlobalBlock
                 U _Z2tfIZ1S2bpMUb0_EUt_EvT_
0000000000000000 r __block_descriptor_tmp
0000000000000020 r __block_literal_global
0000000000000000 D x
0000000000000000 t x_block_invoke

The single symbol ('_Z2tfIZ1S2bpMUb0_EUt_EvT_') emitted for the function
template instantiations reveals that each of the unnamed types were given the
same name: 'Z1S2bpMUb0_EUt_'.  This name is strange in that the 'M' production
corresponding to <pointer-to-member-type> from the Itanium ABI [1] matches the
'<class type>' production (with 'Ub0_'), but is missing a match for '<member
type>'; thus the mangled name appears to be ill-formed.

Clearly, there should be three separate symbol references emitted; each
disambiguated by a discriminator on the <unnamed-type-name> ('Ut_') production
within the name.

[1]:
http://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangle.pointer-to-member-type

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170906/d4bb54c1/attachment.html>


More information about the llvm-bugs mailing list