Quuxplusone / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
https://p1144.godbolt.org/z/jf67zx5hq
Other
1 stars 2 forks source link

Clang accepts `operator==(this const S, const S&) = default` #31

Closed Quuxplusone closed 1 week ago

Quuxplusone commented 7 months ago

https://godbolt.org/z/bKjP8e3nh

struct S {
    int i;
    bool operator==(this const S, const S&) = default;
};

Notice the explicit object parameter is this const S, not this const S&. So it should be rejected; but instead, Clang quietly accepts. Fortunately, it gives the "correct" mangled name and codegen for the by-value argument, so this is more like an accidental language extension rather than a miscompile.

Quuxplusone commented 7 months ago

@Sirraide's https://github.com/llvm/llvm-project/pull/89078 might resolve this, although I doubt it. [EDIT: indeed, it does not]

Quuxplusone commented 1 week ago

Fixed in llvm#100419!