Issue 116961
Summary [Clang] False positive unused private field if defaulted member comparison operator declared out-of-class
Labels clang:diagnostics, false-positive
Assignees
Reporter Maetveis
    Observed:
```c++
class A {
  int used;
  bool operator==(const A&) const;
};

bool A::operator==(const A&) const = default;

class B {
  int used;
 friend bool operator==(const B&, const B&);
};

bool operator==(const B&, const B&) = default;
```

`clang++ -std=c++20 -Wunused-private-field test.cpp`

[Compiler explorer link](https://godbolt.org/z/GnE3fdc45)

```plaintext
<source>:2:7: warning: private field 'used' is not used [-Wunused-private-field]
    2 | int used;
      |       ^
1 warning generated.
Compiler returned: 0
```

Exptected:
No warnings.

_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to