https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101681
Steven Sun <StevenSun2021 at hotmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |StevenSun2021 at hotmail dot com --- Comment #1 from Steven Sun <StevenSun2021 at hotmail dot com> --- The following program compiles. https://godbolt.org/z/aTvchYxYW ``` struct C { void f() {} static_assert(__builtin_constant_p(&C::f)); static_assert(!__builtin_constant_p(&C::f == nullptr)); // not nonzero yet }; static_assert(__builtin_constant_p(&C::f == nullptr)); // nonzero now struct D { void f() {} static_assert(__builtin_constant_p(&C::f == nullptr)); static_assert(!__builtin_constant_p(&D::f == nullptr)); }; static_assert(__builtin_constant_p(&C::f == nullptr)); static_assert(__builtin_constant_p(&D::f == nullptr)); ``` Looks that the `&C::f` is known to be constexpr right after the function was parsed. But only when the class completely parsed, its value was assigned. We can then compare it to nullptr. To make code in comment0 accepted, we need some kind of `not null' mark on the expression tree. 0ne possible way is to assign the `&C::f` in advance, right after it was parsed.