llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.96k stars 11.94k forks source link

Defaulting comparison operator with explicit object parameter #101160

Open Fedr opened 3 months ago

Fedr commented 3 months ago

The following two defaulted equality comparison operators with explicit object parameter

struct A { 
    // #1 valid but rejected in Clang
    //bool operator ==(this A, A) = default;

    // #2 invalid but accepted in Clang
    bool operator ==(this const A, const A &) = default;
};

are processed incorrectly by Clang. 1 is valid but rejected in Clang. 2 is invalid but accepted in Clang. Online demo: https://gcc.godbolt.org/z/MxMnK187c

Related discussion: https://stackoverflow.com/q/78808689/7325599

llvmbot commented 3 months ago

@llvm/issue-subscribers-clang-frontend

Author: Fedor Chelnokov (Fedr)

The following two defaulted equality comparison operators with explicit object parameter ``` struct A { // #1 valid but rejected in Clang //bool operator ==(this A, A) = default; // #2 invalid but accepted in Clang bool operator ==(this const A, const A &) = default; }; ``` are processed incorrectly by Clang. 1 is valid but rejected in Clang. 2 is invalid but accepted in Clang. Online demo: https://gcc.godbolt.org/z/MxMnK187c Related discussion: https://stackoverflow.com/q/78808689/7325599