public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "xgao at nvidia dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/111504] compare operator not defined for recursive data types on C++20
Date: Wed, 20 Sep 2023 21:23:39 +0000 [thread overview]
Message-ID: <bug-111504-4-VlixlMD3KY@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-111504-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111504
--- Comment #2 from Xiang Gao <xgao at nvidia dot com> ---
(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<typename DT::T1, typename DT::T1>::value
is just hasLessThan<int64_t, int64_t>::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<DynamicType>
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<typename DT::T1, typename DT::T1>::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.
next prev parent reply other threads:[~2023-09-20 21:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-20 20:36 [Bug c++/111504] New: " xgao at nvidia dot com
2023-09-20 21:01 ` [Bug c++/111504] " pinskia at gcc dot gnu.org
2023-09-20 21:23 ` xgao at nvidia dot com [this message]
2023-09-22 15:50 ` xgao at nvidia dot com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bug-111504-4-VlixlMD3KY@http.gcc.gnu.org/bugzilla/ \
--to=gcc-bugzilla@gcc.gnu.org \
--cc=gcc-bugs@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).