<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 --- - clang-3.5 emits function definition with internal linkage incorrectly"
href="http://llvm.org/bugs/show_bug.cgi?id=18408">18408</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>clang-3.5 emits function definition with internal linkage incorrectly
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>release blocker
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>-New Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>ken@fsfoundry.org
</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>I use Ubuntu 12.04 and installed clang-3.5 using official repository following
the instructions from <a href="http://llvm.org/apt/">http://llvm.org/apt/</a>
$ clang++ --version
Ubuntu clang version 3.5-1~exp1 (trunk) (based on LLVM 3.5)
Target: x86_64-pc-linux-gnu
Thread model: posix
Clang emits function definition incorrectly with internal linkage, when one of
the function's parameters is an instance of, or a pointer to, a template class
taking a nested class template as its template template parameter. This is kind
of mouthful, the code below reproduces the issue.
template <template <class> class A>
struct TemplateTakingTemplateTemplateParameter {};
template <typename B>
class GlobalTemplate {};
struct OutterClass {
template <typename B>
class InnerTemplate {};
#if(__cplusplus > 199711L)
// No template alias pre-C++11
template <typename B>
using InnerAliasToGlobalTemplate = GlobalTemplate<B>;
#endif
};
typedef TemplateTakingTemplateTemplateParameter<GlobalTemplate> T1;
typedef TemplateTakingTemplateTemplateParameter<OutterClass::InnerTemplate> T2;
#if(__cplusplus > 199711L)
typedef
TemplateTakingTemplateTemplateParameter<OutterClass::InnerAliasToGlobalTemplate>
T3;
#endif
typedef T1* P1;
typedef T2* P2;
#if(__cplusplus > 199711L)
typedef T3* P3;
#endif
void linkageTest(T1) {}
void linkageTest(T2) {}
#if(__cplusplus > 199711L)
void linkageTest(T3) {}
#endif
void linkageTest(P1) {}
void linkageTest(P2) {}
#if(__cplusplus > 199711L)
void linkageTest(P3) {}
#endif
void test()
{
linkageTest(T1());
linkageTest(T2());
#if(__cplusplus > 199711L)
linkageTest(T3());
#endif
linkageTest(P1());
linkageTest(P2());
#if(__cplusplus > 199711L)
linkageTest(P3());
#endif
}
$ # Using clang to generate IR and grep for "internal"
$ clang++ -std=c++1y -S -emit-llvm internal-linkage.cpp -o - | grep define
define void
@_Z11linkageTest39TemplateTakingTemplateTemplateParameterI14GlobalTemplateE()
#0 {
define void
@_Z11linkageTestP39TemplateTakingTemplateTemplateParameterI14GlobalTemplateE(%struct.TemplateTakingTemplateTemplateParameter*)
#0 {
define void @_Z4testv() #1 {
define internal void
@_Z11linkageTest39TemplateTakingTemplateTemplateParameterIN11OutterClass14NestedTemplateEE()
#0 {
define internal void
@_Z11linkageTest39TemplateTakingTemplateTemplateParameterIN11OutterClass27NestedAliasToGlobalTemplateEE()
#0 {
define internal void
@_Z11linkageTestP39TemplateTakingTemplateTemplateParameterIN11OutterClass14NestedTemplateEE(%struct.TemplateTakingTemplateTemplateParameter.0*)
#0 {
define internal void
@_Z11linkageTestP39TemplateTakingTemplateTemplateParameterIN11OutterClass27NestedAliasToGlobalTemplateEE(%struct.TemplateTakingTemplateTemplateParameter.1*)
#0 {
Note 1: linkageTest(T1) and linkageTest(P1) are emitted correctly without
"internal"
Note 2: Incorrect code are also emitted when the parameter is a (const)
lval-ref or an rval-ref
Note 3: It doesn't matter which -std is used here. I tried c++98, c++0x, c++11
and c++1y</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>