<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 - Static constexpr string struct causes unresolved symbols on Windows"
href="https://bugs.llvm.org/show_bug.cgi?id=43280">43280</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Static constexpr string struct causes unresolved symbols on Windows
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</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>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>ToHe_EMA@gmx.de
</td>
</tr>
<tr>
<th>CC</th>
<td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>We are currently exploring to compile our software on Windows with Clang, but
hit a couple Clang/LLVM bugs along the way. Using a static constexpr string in
a struct/class results in unresolved symbols when linking. The minimal code
needed to trigger the bug looks like this:
struct Struct
{
static constexpr char const* ConstexprVar = "Test";
char const* const* Do() { return &ConstexprVar; }
};
int main() { Struct().Do(); }
It is simply compiled with "clang++ Main.cpp" without further options which
then results in this error:
<span class="quote">>Main-70a406.o : error LNK2019: unresolved external symbol "public: static char const * const Struct::ConstexprVar" >(?ConstexprVar@Struct@@2QEBDEB) referenced in
> function "public: char const * const * __cdecl Struct::Do(void)" (?Do@Struct@@QEAAPEBQEBDXZ)
>Main.o : fatal error LNK1120: 1 unresolved externals
>clang++: error: linker command failed with exit code 1120 (use -v to see invocation)</span >
When trying to link with lld, the result is the same:
<span class="quote">>lld: error: undefined symbol: public: static char const *const Struct::ConstexprVar
>>> referenced by Main.o:(public: char const *const * __cdecl Struct::Do(void))</span >
At least the current stable release 8.0 and the nightly build (from here
<a href="https://llvm.org/builds/">https://llvm.org/builds/</a>) are affected.</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>