I'm not sure what happens. Maybe a is wrongly assigned to the inner class. Note that if Inner has a default implementation and is not forward declared, the warning still appears, as long as it is specialized afterward.
a
Inner
❯ cppcheck --version Cppcheck 2.11 ❯ cat test.cpp template <typename T> class Test { public: Test(); int& get() { return a; } private: struct Inner; // or struct Inner {}; int& a; }; template <> struct Test<int>::Inner { }; ❯ cppcheck --enable=style --std=c++20 test.cpp Checking test.cpp ... test.cpp:2:1: style: The class 'Inner' does not declare a constructor although it has private member variables which likely require initialization. [noConstructor] class Test ^
https://trac.cppcheck.net/ticket/11841
Log in to post a comment.
I'm not sure what happens. Maybe
a
is wrongly assigned to the inner class. Note that ifInner
has a default implementation and is not forward declared, the warning still appears, as long as it is specialized afterward.https://trac.cppcheck.net/ticket/11841