<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/56963>56963</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Ambiguous overload on C++ structure returning _Float16
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          thiagomacieira
      </td>
    </tr>
</table>

<pre>
    ```c++
struct Float16
{
    _Float16 f; operator _Float16() const { return f; }
}; 
float f(float f, _Float16 f16) { return f + f16; }
float f(float f, Float16 f16) { return f + f16; }
```

Compile with either `-march=sapphirerapids` or `-target aarch64-linux`.

GCC 12 compiles fine. Clang fails with:
```
test.cpp:6:42: error: use of overloaded operator '+' is ambiguous (with operand types 'float' and 'Float16')
float f(float f, Float16 f16) { return f + f16; }
                                       ~ ^ ~~~
test.cpp:6:42: note: built-in candidate operator+(float, float)
test.cpp:6:42: note: built-in candidate operator+(float, double)
test.cpp:6:42: note: built-in candidate operator+(float, long double)
test.cpp:6:42: note: built-in candidate operator+(float, int)
test.cpp:6:42: note: built-in candidate operator+(float, long)
test.cpp:6:42: note: built-in candidate operator+(float, long long)
test.cpp:6:42: note: built-in candidate operator+(float, __int128)
test.cpp:6:42: note: built-in candidate operator+(float, unsigned int)
test.cpp:6:42: note: built-in candidate operator+(float, unsigned long)
test.cpp:6:42: note: built-in candidate operator+(float, unsigned long long)
test.cpp:6:42: note: built-in candidate operator+(float, unsigned __int128)
1 error generated.
```

Note that there's no offering for `operator+(float, _Float16)` in the listing, though that addition does work as seen in the previous line. The problem appears with the cast operator present only.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy1VUtvnDAQ_jVwGQXxfhw4bNikt556jwwM4NaLkW2S5t93bHZJojZVK-0iy4_x-PP4M_6mlf1r7eXhVjovvrclPHrhQRu1dgYehWQmyjebV5wngb6n8xQMXnIPckHFjFS72YtLL66gk7M2QAtBoVnVvHl7xfGCeHRjNxjsSnKIy73XvNvGYlYfoICidfb3kH9E-V-QnZPz0NWNPC1cILxwMwFShQrI5e7EVDd5yVGzZZm4IiIW3muaAbk5GKZGNMCsX57eCT6vP8kevAf_0jQQxcSX20PDwGcMoBFsHmFgXGi3rZcc_higQW2Cbllong5ySGOqAJWSynZWjSAHkM-oiIce-7fr8uLC3XoBXAM7tXxc5arJXLpTOr-5B_O6oLUWjlPrbq3U7rdNMNUVLwD-7fOKB_CyB9uey-d0zNKgbduVC3PHZ-joDLxnBnc6HBXl-YwNnDvVVUF7ubYCr40qJP0nt4Hm89U5sNHehIFbAD89EQORk7Or4q6z5uNMj_EGBO_YtyDkA_htd_iN-2hTNRhxtiuxD_4i2F9pYzATaZDVanoYhaZgSAoHVNzq6qbPn937rm2V1XKKm1BAcG24PXFDQ7mO07YB63tuuJzpDZJQvkj1A5gGjThfFi4Kn7nVVuGU_ZszSXqvJ6C8gUxtCu98O0ZJc9doWqlxJsMsXgMf6yjPqiJN4rD0-zrpq6RivuFGYH3YBfyi9bQImi2vw5bSV4Vn6bUUXA7pr0rUkzGLtikmfqQyUjRrG1BGooEQz5fmjsL-jh1x9Mi1XlFTJ8urPPGnOonbfCiTPm-jtI8jyjVRlhZ92lVd0WZh5wvWotC1l9172dHndRzGdI4wi5M0T8sgGYquKIsuzKs0TEL00hBPlP0Cu3Eg1eir2sXQrqOmSXsb-m2Safff4AWfrXRHqjYTZ6M8sY4jV8x3Udcu5F9FbsIz">