8000 [Clang] False positive unused private field if defaulted member comparison operator declared out-of-class · Issue #116961 · llvm/llvm-project · GitHub
[go: up one dir, main page]

Skip to content
[Clang] False positive unused private field if defaulted member comparison operator declared out-of-class #116961
Closed
@Maetveis

Description

@Maetveis

Observed:

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

<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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerfalse-positiveWarning fires when it should not

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0