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 via email to