https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80485
Bug ID: 80485 Summary: rejects-valid: constexpr static_cast of pointer-to-member-function to bool Product: gcc Version: 7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: TonyELewis at hotmail dot com Target Milestone: --- GCC rejects the following code (partly adapted from Boost's tribool), which I think is valid: struct dummy { void nonnull() {}; }; typedef void (dummy::*safe_bool)(); constexpr safe_bool a = &dummy::nonnull; static_assert( static_cast<bool>( a ), "" ); int main () { return 0; } I'm compiling with -std=c++14 and I'm seeing these errors: <source>:9:1: error: non-constant condition for static assertion static_assert( static_cast<bool>( a ), "" ); ^~~~~~~~~~~~~ <source>:9:16: error: '(dummy::nonnull != 0)' is not a constant expression static_assert( static_cast<bool>( a ), "" ); ^~~~~~~~~~~~~~~~~~~~~~ Compiler exited with result code 1 This code is accepted by Clang. This looks related to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71896 but that has status "RESOLVED FIXED" but I'm seeing this on "GCC 7 (snapshot)" on godbolt.org (see https://godbolt.org/g/JnrZss ) as well as on my GCC 6.2.0.