<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 variable member template causes clang crash"
href="https://bugs.llvm.org/show_bug.cgi?id=38247">38247</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>static constexpr variable member template causes clang crash
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</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>C++14
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>okannen@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>A basic C++14 construct make Clang crash for all versions of Clang supporting
C++14 I have tested (clang 3.5 to clang 6.0.1).
The use of static constexpr variable member template make clang crash, example:
#include<type_traits>
using namespace std;
struct A{};
struct B{};
template<class U>
struct test
{
template<class T>
static constexpr bool asame =is_same<T,U>::value ;
using type = conditional_t< asame<A> ,B ,A>;
static constexpr bool asameA =test<U>::asame<A> ;
};
static_assert(test<A>::asameA,""); //=> static expression is not an integral
constant expression
static_assert(test<B>::asameA,""); //=> static expression is not an integral
constant expression
static_assert(is_same<A,typename test<A>::type>::value,""); //=> ok, but
static_assert(is_same<B,typename test<A>::type>::value,""); //=> also ok! ->
then clang crash in real code base
For those having the issue, the solution is to replace member variable template
by member of a template class as in:
template<class U>
struct test
{
template<class T>
struct fix_clang{
static constexpr bool asame =is_same<T,U>::value ;
}
using type = conditional_t< fix_clang<A>::asame ,B ,A>;
static constexpr bool asameA =test<U>::fix_clang<A>::asame ;
};</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>