public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "mpolacek at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/114697] New: [DR 233] references in user defined conversions
Date: Thu, 11 Apr 2024 18:33:22 +0000	[thread overview]
Message-ID: <bug-114697-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 114697
           Summary: [DR 233] references in user defined conversions
           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: ---

This should compile:

```
  struct Z {};

  struct A {
    operator Z&();          // #1
    operator const Z&();
  };

  struct B {
    operator Z();           // #2
    operator const Z&&();
  };

  const Z& r1 = A();          // OK, uses #1
  const Z&& r2 = B();         // OK, uses #2
```

but we reject it with:

cwg233.C:13:15: error: conversion from ‘A’ to ‘const Z&’ is ambiguous
   13 | const Z& r1 = A();          // OK, uses #1
      |               ^~~
cwg233.C:4:3: note: candidate: ‘A::operator Z&()’
    4 |   operator Z&();          // #1
      |   ^~~~~~~~
cwg233.C:5:3: note: candidate: ‘A::operator const Z&()’
    5 |   operator const Z&();
      |   ^~~~~~~~

             reply	other threads:[~2024-04-11 18:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-11 18:33 mpolacek at gcc dot gnu.org [this message]
2024-04-11 23:31 ` [Bug c++/114697] " pinskia at gcc dot gnu.org

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-114697-4@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).