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: unassignedclangb...@nondot.org
          Reporter: mpsc...@sandia.gov
                CC: dgre...@apple.com, llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to