<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 - Segfault on initialization of class static variable with explicit instantiation"
href="https://bugs.llvm.org/show_bug.cgi?id=39233">39233</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Segfault on initialization of class static variable with explicit instantiation
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>6.0
</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>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>dehuan@motorola.com
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>related:
<a class="bz_bug_link
bz_status_NEW "
title="NEW - implmenting static member variable of template class as inline variable causes crash"
href="show_bug.cgi?id=32714">https://bugs.llvm.org/show_bug.cgi?id=32714</a>
When a class static variable is initialized
Test code:
#include <iostream>
template<bool foo = true>
class Bar
{
public:
static bool test1()
{
std::cout<<"test1: foo is "<<(foo?"true":"false")<<std::endl;
return true;
}
static const bool dummy;
};
static bool test2()
{
std::cout<<"test2 "<<std::endl;
return true;
}
template<bool foo>
const bool Bar<foo>::dummy
__attribute__ ((used))
= Bar<foo>::test1();
//= test2();// crash as well
template class Bar<false>;
int main()
{
std::cout<<"test done"<<std::endl;
return 0;
}
g++ (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0 output:
test1: foo is false
test done
clang++ output
Segmentation fault (core dumped)
clang++ --version
clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
environment: ubuntu 18.04 x86-64</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>