<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/65137>65137</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang does not use user defined conversion while gcc does
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Horrih
</td>
</tr>
</table>
<pre>
Hello all,
Disclaimer : I am not well versed in the standard, so the issue might come from the gcc side instead, or maybe an UB.
While migrating an app from gcc to clang, we encountered the following issue with user conversion.
```
struct A
{
A(const A& other);
A(A&& other);
};
struct B
{
operator const A();
};
void f()
{
B b;
A a(b);
}
```
The issue can be reproduced on godbolt.org with clang 16 and std=c++14.
Wth c++17 and more the issue goes away.
If I comment out the move constructor, the issue also goes away.
Here is the compiler output
```
src/zob.cpp:15:9: error: no viable conversion from 'B' to 'A'
A a(b);
^
src/zob.cpp:3:5: note: candidate constructor not viable: no known conversion from 'B' to 'const A &' for 1st argument
A(const A& other);
^
src/zob.cpp:4:5: note: candidate constructor not viable: no known conversion from 'B' to 'A &&' for 1st argument
A(A&& other);
^
src/zob.cpp:9:5: note: candidate function
operator const A();
^
src/zob.cpp:4:11: note: passing argument to parameter 'other' here
A(A&& other);
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0VUFz6yYQ_jX4svM8FkiWfdDBfqknubfzzghWEi1iNYDiSX99B6TXOKmTvEs9HoTE8u23y7eLDMH0DrFh1ZlVDxs5x4F880jem2HTkn5pHtFaAmkt49_Z7oHtTsv4YIKy0ozogYkTPIEcwVGEK1oLz-gDajAO4oAQonRaes34dwiUP5kQZoTR9EMERSNC52nMK71SEIxGMC5ElHkTeRjlS4sgHfxx3t7S-DEYm4G8jMb1yUJO0wKXoCKBstL1CeaKgE7R7CJ61NlbR9bSNW1cGF1NHGAO6EGRS1EYcj_97XfrP7-G6GcVYaXB6vMygRPjB0UupCW-B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