<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Mangled names for unnamed local types declared in block expressions in non-static data member initializers lack discriminators"
href="https://bugs.llvm.org/show_bug.cgi?id=34511">34511</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Mangled names for unnamed local types declared in block expressions in non-static data member initializers lack discriminators
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>4.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>thonerma@synopsys.com
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>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]:
<a href="http://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangle.pointer-to-member-type">http://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangle.pointer-to-member-type</a></pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>