<html>
<head>
<base href="https://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 --- - Export attribute on inline template method not ignored"
href="https://llvm.org/bugs/show_bug.cgi?id=31695">31695</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Export attribute on inline template method not ignored
</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>Windows NT
</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>Driver
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>steveire@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Given a header
#ifdef BUILDING_LIB
#define EXPORT __declspec(dllexport)
#else
#define EXPORT __declspec(dllimport)
#endif
namespace MyNS {
EXPORT void func();
template<int size = 3>
EXPORT inline int someFunc(int input = size);
}
template<int size>
int MyNS::someFunc(int input)
{
return input * 2;
}
and trivial source file:
#include "export-inline.h"
namespace MyNS {
void func()
{
}
}
and consumer:
#include "export-inline.h"
int main()
{
MyNS::func();
int sf = MyNS::someFunc(43);
return 0;
}
and buildsystem:
add_library(sh SHARED
export-inline.cpp
)
target_compile_definitions(sh PRIVATE BUILDING_LIB)
add_executable(shconsumer export-consumer.cpp)
target_link_libraries(shconsumer sh)
clang-cl fails to ignore the export attribute and the link fails.
unresolved external symbol "__declspec(dllimport) int __cdecl
MyNS::someFunc<3>(int)" (__imp_??$someFunc@$02@MyNS@@YAHH@Z) referenced in
function main</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>