[libcxx] [lld] [clang] [lldb] [clang-tools-extra] [flang] [libc] [compiler-rt] [llvm] [Clang][C++23] Implement P2448R2: Relaxing some constexpr restrictions (PR #77753)

via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 24 06:18:42 PST 2024


================
@@ -9108,7 +9123,8 @@ bool Sema::CheckExplicitlyDefaultedComparison(Scope *S, FunctionDecl *FD,
   //   declaration, it is implicitly considered to be constexpr.
   // FIXME: Only applying this to the first declaration seems problematic, as
   // simple reorderings can affect the meaning of the program.
-  if (First && !FD->isConstexpr() && Info.Constexpr)
+  if ((First && !FD->isConstexpr() && Info.Constexpr) ||
+      getLangOpts().CPlusPlus23)
----------------
cor3ntin wrote:

> isn't Info.Constexpr always true in c++ mode?

**C++23**, sorry 

> Should the call to such function be allowed? I suppose not due to-literal member. The problem is, there result is same with or without this change. I meant to apply this

Hum right, i was thinking we could have a `if(false)` in the comparison function, but that's for defaulted function so it doesn't work.

The error message should be different though, right? something like "the call to operator== is not a constant expression" ?




https://github.com/llvm/llvm-project/pull/77753


More information about the cfe-commits mailing list