[cfe-dev] C++ operator overload miscompilation

Adam Nowacki via cfe-dev cfe-dev at lists.llvm.org
Thu Jun 8 03:22:54 PDT 2017


For C++ code:

struct A {
    operator int();
};
bool f() {
    bool operator==(const A &, const A &);
    return A() == A();
}

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.
Other compilers handle this correctly (gcc, icc, cl).

https://godbolt.org/g/IpXmfw



More information about the cfe-dev mailing list