Found in 2.15 and 2.16
#include <iostream> namespace Foo { namespace Bar { class Baz { int i; int j{1}; public: Baz() : i{0} {}; int get_i() const { return i; }; int get_j() const { return j; }; }; } using Baz = Bar::Baz; } int main() { Foo::Baz baz; std::cout << baz.get_i() << baz.get_j(); return 0; }
Output:
C:\repos\cppcheck_false_positives>cppcheck cppcheck_false_positives.cpp --enable=all --suppress=missingIncludeSystem --template=gcc --library=windows.cfg --platform=win64 --std=c++20 Checking cppcheck_false_positives.cpp ... cppcheck_false_positives.cpp:14:7: warning: Member variable 'Baz::i' is not initialized. [uninitMemberVarPrivate] int i; ^
Or alternatively:
namespace Foo { namespace Bar { class Baz { int i; public: Baz() : i{0} {}; int get() const { return i; }; }; } using Baz = Bar::Baz; } int main() { Foo::Baz baz; std::cout << baz.get(); return 0; }
C:\cppcheck_false_positives>cppcheck cppcheck_false_positives.cpp --enable=all --suppress=missingIncludeSystem --template=gcc --library=windows.cfg --platform=win64 --std=c++20 Checking cppcheck_false_positives.cpp ... cppcheck_false_positives.cpp:12:1: warning: The class 'Baz' does not declare a constructor although it has private member variables which likely require initialization. [noConstructor] class Baz ^
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/13354
Log in to post a comment.
Found in 2.15 and 2.16
Output:
Or alternatively:
Output:
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/13354