[llvm-bugs] [Bug 39233] New: Segfault on initialization of class static variable with explicit instantiation
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Oct 9 12:12:19 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=39233
Bug ID: 39233
Summary: Segfault on initialization of class static variable
with explicit instantiation
Product: clang
Version: 6.0
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: dehuan at motorola.com
CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
related:
https://bugs.llvm.org/show_bug.cgi?id=32714
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
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20181009/3319c73c/attachment.html>
More information about the llvm-bugs
mailing list