[19 regression] Wrong overload resolution rules for CTAD in copy-initialization allowing double user-defined conversion
Open
clang:frontend
confirmed
regression:19
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Testcase:
```c++
struct Wrap { Wrap(int); };
template struct Class { Class(int); };
Class(Wrap) -> Class;
Class c = 0;
```
This is invalid. The CTAD rules say that we are supposed to form a class whose constructors are the guides of `Class` and try initializing it:
```c++
struct GuideClass {
GuideClass(Wrap);
// ... other constructors ...
};
GuideClass c = 0;
```
But this fails due to [over.best.ics]/4.4, because it would invoke two user-defined conversions (one from `int` to `Wrap` and another from `Wrap` to `GuideClass`). So CTAD should fail here.
Clang 18 and earlier got this right; Clang 19 onwards incorrectly deduces `Class` -> `Class`.
Contributor guide
Assessment
This issue has not been assessed yet.