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

    <tr>
        <th>Summary</th>
        <td>
            "Wrong" name mangling for operator== in extern "C"
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    ```c++
struct mytype {};

extern "C" {
bool operator==(const mytype & a, const mytype & b);
}

bool foo(const mytype & a)
{
 return a == a;
}
```
Clang:
```asm
_Z3fooRK6mytype:
 mov     rsi, rdi
        jmp _ZeqRK6mytypeS1_@PLT
```
GCC:
```asm
_Z3fooRK6mytype:
        mov rsi, rdi
        jmp     _Zeq
```
I don't particularly care which name is used, but you're supposed to match GCC, right? (Or is GCC the one that's wrong? I'll file this against them instead if you prefer that.)

https://godbolt.org/z/xhh7T7KGd

<https://eel.is/c++draft/over.literal#6> bans extern "C" for user defined literals, and such language is absent on other operators, so I think extern "C" must be tolerated on other opeerators. But they should probably be a warning.

(Originally found in mingw headers https://godbolt.org/z/xx4EP9bxG - they forgot an extern "C++" in guiddef.h.)
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyUVFGL4zYQ_jXKy7BGGTtx8uCHbPayLFfo0R4U7mUZW2NbV1lyJXmz6a8vcty7JuUoFYIESd_3zXwzHgpBd5a5EptHsXla0RR756uDaci7Ve3UpRJbed2NwMe05SFEPzURhku8jAyifBTlk8jTjZAHfo_sLQjEo0Ccb-Whds6AG9lTdF7kT2njrnE2fKfBLZDAI_zrtBa4X-jLp6vIzNc69wOS_fw2IcBznLwFgqsq0A3T37kJeTgasp3ID_88pjAIeXj9krfO_fJxexW5voHBvUFaPugUtVc6nS7r6zDC6xf-4xvo1_WrKOSnnz7fqT4fj_9Dc1lJ-oeyaSXpO6EXUM4KLCOM5KNuJkPeXKAhz3DuddODpYFBB5gCq0RdTxEubhJYeoYwjaMLrCA6GCg2PaTIUwC666PITyBw97NP-OfjEWLP4CxD7CkKLAOcvUvunuBFYGkMtNqkWx2AOtKpgrHnAdI_JgW6TdIwem7ZzyzZUlV56GMcQzIETwJPnVO1MzFzvhN4-lPg6b3vy8_lx2d1fS7y4y2C2WQ6CDwtDa08tVHgyb2xz4yO7MkIzLci_wA12QB3Hd06nzzyoLjVlhUsmJDsIKsgTE0PqZsm6mZHqQ5sIzgLLvbsv30IMyI4eElO2N_vhYYpRKgZojPpPasbhoUig8dpNu8CoXeTUTB6V1NtLglKcCZvte2yxYxUJN1pS8ZcoHWTVaAtDNp2Z-iZFPsA_2nwe_Hh075-f4aHq3DrfOcikL3NYJ4WiEmgm7RS3GZ9KuNKVbna53tacbUui7KU-Vbmq76qdzW1ci3L_W6r1sWubPaSdvsCmXhXbPOVrlDiRm5QyvU6xzxTO1XnddEoVpSXXIhC8kDaZMa8DSnklQ5h4mpdyO2mWBmq2YR52CFaPsN8KxDT7PNVAj3UUxdEIY0OMXyniToargTib3MjI14_l4FsZ7Tt5qa4nW8p7duCriZvqjtzdeynOmvcIPCUxJafh9G7r9yktpxDTO265PBW4V8BAAD__3srwjA">