Skip to content

Clang fails to warn -Wunused-private-field #116270

Closed
@VitorRamos

Description

@VitorRamos

clang version: 19.1
os: ubuntu 22.04

class A
{
public:
   A() : m_x(0)
   {
   }
private:
   const int m_x;
};

#ifdef BUG
class C
{
    friend auto operator==(C, C) -> bool = default;
};
#endif

int main()
{
   [[maybe_unused]] auto c = A();
}

clang++ -std=c++20 -Wall main.cpp

main.cpp:8:14: warning: private field 'm_x' is not used [-Wunused-private-field]
    8 |    const int m_x;
      |              ^
1 warning generated.

clang++ -DBUG -std=c++20 -Wall main.cpp

no warnings

Metadata

Metadata

Assignees

Labels

clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerconfirmedVerified by a second partyfalse-negativegood first issuehttps://github.com/llvm/llvm-project/contribute

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions