Invoking `constexpr` member function through reference - clang vs gcc
问题 Consider the following example ( snippet (0) ): struct X { constexpr int get() const { return 0; } }; void foo(const X& x) { constexpr int i = x.get(); } int main() { foo(X{}); } The above example compiles with all versions of g++ prior to g++ 10.x , and never compiled under clang++ . The error message is: error: 'x' is not a constant expression 8 | constexpr int i = x.get(); | live example on godbolt.org The error kind of makes sense, as x is never a constant expression in the body of foo ,