Issue |
74212
|
Summary |
Reference initialization involving deleted conversion function wrongly diagnosed as "ambiguous"
|
Labels |
new issue
|
Assignees |
|
Reporter |
t3nsor
|
Code:
```
struct Cat { };
struct Dog {
operator Cat();
operator Cat&() = delete;
};
Cat const& r = Dog{};
```
Clang 17.0.1 (all language versions from c++11 to c++2b) gives the wrong diagnostic, reproduced below:
```
<source>:6:12: error: reference initialization of type 'const Cat &' with initializer of type 'Dog' is ambiguous
6 | Cat const& r = Dog{};
| ^ ~~~~~
<source>:3:5: note: candidate function
3 | operator Cat();
| ^
<source>:4:5: note: candidate function has been explicitly deleted
4 | operator Cat&() = delete;
| ^
```
There's no ambiguity; under [[dcl.init.ref]/5.1](http://eel.is/c++draft/dcl.init.ref#5.1) and [[over.match.ref]/1.1](http://eel.is/c++draft/over.match.ref#1.1), the first stage of overload resolution involves `operator Cat&` only.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs