public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/114549] New: GCC >= 10.1 selects the wrong overload of C++20 reversed operator== function
@ 2024-04-01 17:28 cpeterson at mozilla dot com
  2024-04-01 17:33 ` [Bug c++/114549] [11/12/13 Regression] " pinskia at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: cpeterson at mozilla dot com @ 2024-04-01 17:28 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114549

            Bug ID: 114549
           Summary: GCC >= 10.1 selects the wrong overload of C++20
                    reversed operator== function
           Product: gcc
           Version: 10.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: cpeterson at mozilla dot com
  Target Milestone: ---

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. This is Firefox bug
https://bugzilla.mozilla.org/show_bug.cgi?id=1880776

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;
}
```

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-04-02 11:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-01 17:28 [Bug c++/114549] New: GCC >= 10.1 selects the wrong overload of C++20 reversed operator== function cpeterson at mozilla dot com
2024-04-01 17:33 ` [Bug c++/114549] [11/12/13 Regression] " pinskia at gcc dot gnu.org
2024-04-01 17:41 ` cpeterson at mozilla dot com
2024-04-01 17:44 ` pinskia at gcc dot gnu.org
2024-04-01 17:49 ` mpolacek at gcc dot gnu.org
2024-04-02 11:32 ` rguenth at gcc dot gnu.org

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).