Issue |
125233
|
Summary |
`-Wunused-function` false positive for `friend operator<=>` in unnamed namespace
|
Labels |
false-positive
|
Assignees |
|
Reporter |
Eisenwave
|
```cpp
#include <compare>
namespace {
struct S {
friend auto operator<=>(const S&, const S&) = default;
};
[[maybe_unused]] bool awoo(S a, S b) { return a == b; }
}
```
When compiling with `-std=c++20 -Wunused-function`, we get this output:
```cpp
<source>:6:17: warning: unused function 'operator<=>' [-Wunused-function]
6 | friend auto operator<=>(const S&, const S&) = default;
| ^~~~~~~~
1 warning generated.
```
This is obviously a false positive. If `<=>` was unused, then `a == b` wouldn't compile.
This only occurs in a very niche circumstance. Any one of the following doesn't get a warning:
- using `a <=> b`
- not using an unnamed namespace
- defaulting `operator==` and using `a != b`, which similarly relies on _expression_ rewriting
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs