Re: Bug in GCC's resolution of C++20 reversed operator== functions?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 31 Mar 2024, 23:02 Chris Peterson, <cpeterso@xxxxxxxxxxxx> 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.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux