https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80456
Bug ID: 80456 Summary: calling constexpr member function from volatile-qualified member function: error: ‘this’ is not a constant expression Product: gcc Version: 6.3.1 Status: UNCONFIRMED Keywords: rejects-valid Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: redi at gcc dot gnu.org Target Milestone: --- This valid code is rejected: struct A { static constexpr bool test() noexcept { return true; } void f() volatile { constexpr bool b = test(); } }; void g() { A a; a.f(); } vol.cc: In member function ‘void A::f() volatile’: vol.cc:5:29: error: ‘this’ is not a constant expression constexpr bool b = test(); ^ This complicates adding static assertions to std::atomic<T*>, as it has lots of volatile-qualified member functions which need to enforce requirements.