public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/107918] New: P2468R2 and operator ambiguity
@ 2022-11-29 16:18 mpolacek at gcc dot gnu.org
  2022-11-29 16:28 ` [Bug c++/107918] " pinskia at gcc dot gnu.org
  2022-11-29 16:45 ` dacamara.cameron at gmail dot com
  0 siblings, 2 replies; 3+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-11-29 16:18 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 107918
           Summary: P2468R2 and operator ambiguity
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mpolacek at gcc dot gnu.org
  Target Milestone: ---

I hear that

// Global scope.
template <typename>
struct S {
  friend bool operator==(S&&, const S&) { return true; }
  friend bool operator!=(S&&, const S&) { return true; }
};

using U = S<int>;

bool b = U{} == U{};

shouldn't be ambiguous according to P2468R2
<https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2468r2.html>, but
with -std=c++20 we emit:

warning: C++20 says that these are ambiguous, even though the second is
reversed

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

* [Bug c++/107918] P2468R2 and operator ambiguity
  2022-11-29 16:18 [Bug c++/107918] New: P2468R2 and operator ambiguity mpolacek at gcc dot gnu.org
@ 2022-11-29 16:28 ` pinskia at gcc dot gnu.org
  2022-11-29 16:45 ` dacamara.cameron at gmail dot com
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-29 16:28 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
              /* Ambiguity between normal and reversed comparison operators
                 with the same parameter types.  P2468 decided not to go with
                 this approach to resolving the ambiguity, so pedwarn.  */

hmmm

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

* [Bug c++/107918] P2468R2 and operator ambiguity
  2022-11-29 16:18 [Bug c++/107918] New: P2468R2 and operator ambiguity mpolacek at gcc dot gnu.org
  2022-11-29 16:28 ` [Bug c++/107918] " pinskia at gcc dot gnu.org
@ 2022-11-29 16:45 ` dacamara.cameron at gmail dot com
  1 sibling, 0 replies; 3+ messages in thread
From: dacamara.cameron at gmail dot com @ 2022-11-29 16:45 UTC (permalink / raw)
  To: gcc-bugs

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

Cameron <dacamara.cameron at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dacamara.cameron at gmail dot com

--- Comment #2 from Cameron <dacamara.cameron at gmail dot com> ---
Just to expand on why the comparison below is no longer an ambiguity, we hit
[over.oper.match]/4 and need to see if there is an existing 'operator!=' with
the same signature as our 'operator==' candidate.  The implicit specialization
of 'S<int>' will have produced such a corresponding 'operator!='.

Additionally, I am curious as to why the implementation of P2468R2 issues a
warning as opposed to a real error during compilation.

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

end of thread, other threads:[~2022-11-29 16:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-29 16:18 [Bug c++/107918] New: P2468R2 and operator ambiguity mpolacek at gcc dot gnu.org
2022-11-29 16:28 ` [Bug c++/107918] " pinskia at gcc dot gnu.org
2022-11-29 16:45 ` dacamara.cameron at gmail dot com

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