Issue |
104413
|
Summary |
C++23 default comparisons is incorrectly rejected
|
Labels |
new issue
|
Assignees |
|
Reporter |
marco-antognini-sonarsource
|
According to https://eel.is/c++draft/class.compare#default-1, the following C++23 program should compile.
```cpp
struct A {
bool operator ==(this A, A) = default;
};
int main() {
return A{}.operator ==(A{});
}
```
but Clang (18.1 and trunk) reports
```
<source>:2:20: error: defaulted member equality comparison operator must be const-qualified
2 | bool operator ==(this A, A) = default;
| ^
| const
<source>:2:8: error: invalid parameter type for defaulted equality comparison operator; found 'A', expected 'const A &'
2 | bool operator ==(this A, A) = default;
| ^ ~
2 errors generated.
```
FWIW, GCC accepts it.
Reproducible at https://godbolt.org/z/qM57nxz5d
See also https://stackoverflow.com/a/78808748/24103368 from @brevzin.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs