[llvm-bugs] [Bug 38247] New: static constexpr variable member template causes clang crash
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Jul 20 08:03:05 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=38247
Bug ID: 38247
Summary: static constexpr variable member template causes clang
crash
Product: clang
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: release blocker
Priority: P
Component: C++14
Assignee: unassignedclangbugs at nondot.org
Reporter: okannen at gmail.com
CC: llvm-bugs at lists.llvm.org
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 ;
};
--
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/20180720/881eda90/attachment.html>
More information about the llvm-bugs
mailing list