<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/134287>134287</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang accepts ambiguous inherited constructor
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
plopresti
</td>
</tr>
</table>
<pre>
See https://stackoverflow.com/q/79553477/ and https://stackoverflow.com/a/71197138/
```
class Option;
class Base
{
public:
explicit Base(Option opt);
};
class Derived : public Base
{
public:
using Base::Base;
explicit Derived(const Option &opt);
};
Derived
doit(const Option &opt)
{
return Derived(opt);
}
```
[Live example on Godbolt](https://godbolt.org/z/ddPr6WYKc)
GCC and ICC reject the call to Derived(opt) as ambiguous. Clang allows it.
According to https://stackoverflow.com/a/71197138/:
> GCC is correct here: there is a tiebreaker that prefers direct over inherited constructors ([over.match.best.general]/2.7), but it applies only if they have the same parameter types (ignoring those whose default arguments are being used).
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJycVE2vpDYQ_DXm0loE9jAwBw7MTFhFiZRIOUQ5GrsBZw0mdjNvJ78-MrDKvpe8KFqpNR-4u7qoKlmGYIYZsWbFlRX3RK40Ol8v1i0eA5mkc_pZ_4III9ESmGgYbxlvA0n1yT3Q99a9pMpNjLd_MN6Wl6IQp7JkvAU56_8xJeNUnl_KXFSxK2tinbOjskZZGQL8tJBxMxPXvWF_eJUB4_8yPl3WzhoVd2UNAH5erFGG9h5e7fPgFmL8csCU9zd4d_TmgRqYaGCH-68VazDzsDeIholm_3V9vf6AZLxSbg50vAcwfn6PypeJrNHO0PuDX0gBeKTVz1-tegv9WtBYxfVH80DAz3JaLIKb4aPTnbPEijvj1Wvbhv0odX5gvP2T8Vbrn_35199-UAeRrPl4u22Gf3-7gcffURHQiKCktUDuH9xABpBTZ4bVrSGFm5XzANJa9xLAULpjNko5r6PI5L4hSZtNscR3EOmZAMp5H6mN6KNpkaLHeCCBDHYe5Sf0QKMkWDz26ANos03EXWDmEb0h1LB54ldFzgdgvGLFNXakkyQ1ph0GSgec0Uu7CdrytIxS8Rt0K4EhkMtiDQZws32C6SOTJ4zygZtsQU4Ii_RyQoqEngtua8wwO78JMrqA8LJ9auzlagmkH9YJZwogPUKHsW8NUfTLIWiia6Ev4iITrPPyJMpMVGWRjHXR91LmspdlJSTHvO9V32vBz_qsS95fElPzjBfZKRN5lef5KdVCoVBK9Fkpcn0u2CnDSRqbWvuYYlISE8KKdS5OvCoTKzu0YbtlOFfRbcZ5vHB8HQc-dOsQ2CmzJlD4G4IMWayPcCiFC32Vmn93I1m9rd_E19C4dkdIIvbx9WHxLgaV8XbjGhhvD7qPmv8VAAD___QunKo">