* Bug in GCC's resolution of C++20 reversed operator== functions?
@ 2024-03-31 22:00 Chris Peterson
2024-04-01 8:59 ` Jonathan Wakely
2024-04-01 17:35 ` Chris Peterson
0 siblings, 2 replies; 3+ messages in thread
From: Chris Peterson @ 2024-03-31 22:00 UTC (permalink / raw)
To: gcc-help
[-- Attachment #1: Type: text/plain, Size: 1101 bytes --]
While updating Firefox from -std=c++17 to -std=c++20, I found a case where
GCC's resolution of C++20 reversed operator== functions behaves differently
from the Clang, MSVC, and ICX compilers. I believe this difference was a
regression in GCC 10.1.
Here's a Godbolt test case comparing those compilers' output:
https://godbolt.org/z/qneax5oaW
```
#include <type_traits>
struct Thing {
template <typename T>
bool operator==(const T& rhs) const {
/* This operator== is selected by:
* GCC versions >= 10.1 -std=c++17
* GCC version 9.5 -std=c++2a
* Clang 18.1 -std=c++2a
* MSVC 19.38 -std=c++20
* Intel's ICX 2024.0.0 -std=c++20
*/
return false;
}
};
template <typename T>
bool operator==(T const& lhs, Thing const& rhs) {
/* This operator== is selected by:
* GCC versions >= 10.1 -std=c++2a
*/
return true;
}
bool test() {
Thing const v{};
return v == 3;
}
```
(I have an account on the GCC Bugzilla, but I'm not able to log in or reset
my password to file a bug there.)
chris
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Bug in GCC's resolution of C++20 reversed operator== functions?
2024-03-31 22:00 Bug in GCC's resolution of C++20 reversed operator== functions? Chris Peterson
@ 2024-04-01 8:59 ` Jonathan Wakely
2024-04-01 17:35 ` Chris Peterson
1 sibling, 0 replies; 3+ messages in thread
From: Jonathan Wakely @ 2024-04-01 8:59 UTC (permalink / raw)
To: Chris Peterson; +Cc: gcc-help
[-- Attachment #1: Type: text/plain, Size: 1344 bytes --]
On Sun, 31 Mar 2024, 23:02 Chris Peterson, <cpeterso@cpeterso.com> wrote:
> While updating Firefox from -std=c++17 to -std=c++20, I found a case where
> GCC's resolution of C++20 reversed operator== functions behaves differently
> from the Clang, MSVC, and ICX compilers. I believe this difference was a
> regression in GCC 10.1.
>
> Here's a Godbolt test case comparing those compilers' output:
>
> https://godbolt.org/z/qneax5oaW
>
> ```
> #include <type_traits>
>
> struct Thing {
> template <typename T>
> bool operator==(const T& rhs) const {
> /* This operator== is selected by:
> * GCC versions >= 10.1 -std=c++17
> * GCC version 9.5 -std=c++2a
> * Clang 18.1 -std=c++2a
> * MSVC 19.38 -std=c++20
> * Intel's ICX 2024.0.0 -std=c++20
> */
> return false;
> }
> };
>
> template <typename T>
> bool operator==(T const& lhs, Thing const& rhs) {
> /* This operator== is selected by:
> * GCC versions >= 10.1 -std=c++2a
> */
> return true;
> }
>
> bool test() {
> Thing const v{};
> return v == 3;
> }
> ```
>
> (I have an account on the GCC Bugzilla, but I'm not able to log in or reset
> my password to file a bug there.)
>
This should be reported to bugzilla so I'll contact you off-list to resolve
the login issues.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Bug in GCC's resolution of C++20 reversed operator== functions?
2024-03-31 22:00 Bug in GCC's resolution of C++20 reversed operator== functions? Chris Peterson
2024-04-01 8:59 ` Jonathan Wakely
@ 2024-04-01 17:35 ` Chris Peterson
1 sibling, 0 replies; 3+ messages in thread
From: Chris Peterson @ 2024-04-01 17:35 UTC (permalink / raw)
To: gcc-help
[-- Attachment #1: Type: text/plain, Size: 1399 bytes --]
I filed a bug in Bugzilla:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114549
On Sun, Mar 31, 2024 at 3:00 PM Chris Peterson <cpeterso@cpeterso.com>
wrote:
> While updating Firefox from -std=c++17 to -std=c++20, I found a case where
> GCC's resolution of C++20 reversed operator== functions behaves differently
> from the Clang, MSVC, and ICX compilers. I believe this difference was a
> regression in GCC 10.1.
>
> Here's a Godbolt test case comparing those compilers' output:
>
> https://godbolt.org/z/qneax5oaW
>
> ```
> #include <type_traits>
>
> struct Thing {
> template <typename T>
> bool operator==(const T& rhs) const {
> /* This operator== is selected by:
> * GCC versions >= 10.1 -std=c++17
> * GCC version 9.5 -std=c++2a
> * Clang 18.1 -std=c++2a
> * MSVC 19.38 -std=c++20
> * Intel's ICX 2024.0.0 -std=c++20
> */
> return false;
> }
> };
>
> template <typename T>
> bool operator==(T const& lhs, Thing const& rhs) {
> /* This operator== is selected by:
> * GCC versions >= 10.1 -std=c++2a
> */
> return true;
> }
>
> bool test() {
> Thing const v{};
> return v == 3;
> }
> ```
>
> (I have an account on the GCC Bugzilla, but I'm not able to log in or
> reset my password to file a bug there.)
>
> chris
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-04-01 17:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-31 22:00 Bug in GCC's resolution of C++20 reversed operator== functions? Chris Peterson
2024-04-01 8:59 ` Jonathan Wakely
2024-04-01 17:35 ` Chris Peterson
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).