[Bug c++/111504] compare operator not defined for recursive data types on C++20

2023-09-22 Thread xgao at nvidia dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111504

--- Comment #3 from Xiang Gao  ---
Cross posted at: https://github.com/llvm/llvm-project/issues/67056

[Bug c++/111504] compare operator not defined for recursive data types on C++20

2023-09-20 Thread xgao at nvidia dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111504

--- Comment #2 from Xiang Gao  ---
(In reply to Andrew Pinski from comment #1)
> Fails for the same reason with clang (both with libstdc++ and libc++) 
> 
> Are you sure this is valid C++ 20 code?

I am not 100% sure, but my understanding is, for the SFINAE in
  inline constexpr bool operator<(const DT& x, const DT& y)
The first condition
  hasLessThan::value
is just hasLessThan::value, which should be true, and (true
|| anything) is always true.

So the condition in SFINAE should be easily evaluated as true. So the operator<
for DynamicType should be defined.

And if operator< is defined, then the operator<=> of std::vector
should also be defined. This can be validated by changing the definition of
operator< by only keeping the first condition:

template <
typename DT,
typename = std::enable_if_t<
(hasLessThan::value)>>
inline constexpr bool operator<(const DT& x, const DT& y) {
  // implementation omitted
  return true;
}

and then both g++ and clang++ will pass.

I do observe the same error on clang, but this https://cpp.sh/ seems to compile
without problem on C++20.

[Bug c++/111504] compare operator not defined for recursive data types on C++20

2023-09-20 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111504

--- Comment #1 from Andrew Pinski  ---
Fails for the same reason with clang (both with libstdc++ and libc++) 

Are you sure this is valid C++ 20 code?