Issue 183370
Summary [19 regression] Wrong overload resolution rules for CTAD in copy-initialization allowing double user-defined conversion
Labels new issue
Assignees
Reporter zygoloid
    Testcase:

```c++
struct Wrap { Wrap(int); };
template <bool> struct Class { Class(int); };
Class(Wrap) -> Class<true>;
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<true>`.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to