[llvm-bugs] [Bug 35390] New: static constexpr data member of non static member not considered constant
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Nov 22 10:17:28 PST 2017
https://bugs.llvm.org/show_bug.cgi?id=35390
Bug ID: 35390
Summary: static constexpr data member of non static member not
considered constant
Product: clang
Version: 5.0
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: mpscogg at sandia.gov
CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
/********************************************
The following code works and works as expected in g++, and not in clang++
The template is not necessary for the failure,
*********************************************/
template <unsigned int const SIGNAL_HASH>
class EventBase
{
public:
static constexpr unsigned int const signal { SIGNAL_HASH };
};
class Actor
{
public:
EventBase<42> actor_event;
int processEvent(unsigned int const _event)
{
switch(_event){
case actor_event.signal: //Compiles in g++ and NOT clang++
break;
default:
return 1;
}
return 0;
}
};
int main() {
}
/****************************************
Ubuntu14.04.1
g++ 5.4.1
clang++-5.0/6.0
CXX -std=c++14 clang-constexpr-switch-error.cpp
error:
clang-test-T.cpp:16:12: error: case value is not a constant expression
case actor_event.signal: //Compiles in g++ and NOT clang++
^~~~~~~~~~~~~~~~~~
clang-test-T.cpp:16:12: note: implicit use of 'this' pointer is only allowed
within the evaluation of a call to a 'constexpr' member function
*******************************************/
--
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/20171122/8e63c671/attachment.html>
More information about the llvm-bugs
mailing list