Issue 140654
Summary "Wrong" name mangling for operator== in extern "C"
Labels new issue
Assignees
Reporter Alcaro
    ```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.)
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to