llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.36k stars 11.71k forks source link

Garbled wording for error about constexpr `<=>` invoking a non-constexpr comparator #93702

Open pkasting opened 4 months ago

pkasting commented 4 months ago

The following code generates a garbled error message (compile with -std=c++20 -Wno-defaulted-function-deleted):

struct S {
  bool operator==(const S& s) const;
};

struct T {
  constexpr auto operator<=>(const T&) const = default;
  const S s;
};

Live repro: https://godbolt.org/z/rTd1eMrM9

I get: "error: defaulted definition of three-way comparison operator cannot be declared constexpr because for which the corresponding implicit 'operator==' invokes a non-constexpr comparison function"

Maybe this meant to say something like "error: defaulted definition of three-way comparison operator cannot be declared constexpr because the corresponding implicit 'operator==' invokes a non-constexpr comparison function"? Or "error: defaulted definition of three-way comparison operator cannot be declared constexpr because it invokes a corresponding implicit 'operator==' which is not constexpr"? Not sure exactly what wording corresponds precisely with the underlying behavior.

shafik commented 4 months ago

Looks like this wording came in via f9a14782000e6

CC @amykhuang