<html>
<head>
<base href="http://llvm.org/bugs/" />
</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 --- - Miscompile when linking variable templates instantiated from similarly named local types"
href="http://llvm.org/bugs/show_bug.cgi?id=19480">19480</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Miscompile when linking variable templates instantiated from similarly named local types
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.4
</td>
</tr>
<tr>
<th>Hardware</th>
<td>Other
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</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++1y
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>hstong@ca.ibm.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>The functions foo() in the program below can only reside in their native
translation unit.
The local classes Foo in each foo() are distinct entities.
Clang seems to treat the x<Foo> specializations as one entity.
### TRANSLATION UNIT A:
<span class="quote">> cat badvartmpllinkA.cc </span >
template <typename T> int x = 42;
static int &foo() {
struct Foo { };
return x<Foo>;
}
int &bar() { return foo(); }
Return: 0x00:0
### TRANSLATION UNIT B:
<span class="quote">> cat badvartmpllinkB.cc </span >
template <typename T> int x = 42;
static int &foo() {
struct Foo { };
return x<Foo>;
}
int &bar();
int main() { &bar() == &foo() ? throw 0 : (void)0; }
Return: 0x00:0
### COMPILER INVOCATION:
<span class="quote">> clang++ -std=c++1y -pedantic-errors badvartmpllinkA.cc badvartmpllinkB.cc -o badvartmpllink </span >
Return: 0x00:0
### OUTPUT FROM RESULTING BINARY:
<span class="quote">> ./badvartmpllink </span >
terminate called after throwing an instance of 'int'
Aborted (core dumped)
Return: 0x86:134
### VERSION INFORMATION:
<span class="quote">> clang++ -v</span >
clang version 3.4 (tags/RELEASE_34/final)
Target: powerpc64-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/lib/gcc/ppc64-redhat-linux/4.4.4
Found candidate GCC installation: /usr/lib/gcc/ppc64-redhat-linux/4.4.6
Selected GCC installation: /usr/lib/gcc/ppc64-redhat-linux/4.4.6
Return: 0x00:0</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>