[cfe-dev] C++ operator overload miscompilation
Dimitry Andric via cfe-dev
cfe-dev at lists.llvm.org
Thu Jun 8 07:51:22 PDT 2017
On 8 Jun 2017, at 12:22, Adam Nowacki via cfe-dev <cfe-dev at lists.llvm.org> wrote:
>
> For C++ code:
>
> struct A {
> operator int();
> };
> bool f() {
> bool operator==(const A &, const A &);
> return A() == A();
> }
Any particular reason why you declare operator== inside f()? Normally, such declarations are put at the top level.
> clang emits calls to A::operator int() and then performs the == comparison on ints - which is incorrect, only a call to operator==(const A &, const A &) should be emitted.
That said, it's weird that it doesn't find operator== here. I think it has something to do with declaring it inside the function, instead of at the top level.
-Dimitry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 194 bytes
Desc: Message signed with OpenPGP
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170608/2b37e249/attachment.sig>
More information about the cfe-dev
mailing list