Menu

cppcheck false positive for uninitialized class members

2023-10-27
2023-10-31
  • Christian Buchner

    Hi all,

    a reproducer code that I just posted to the LLVM bug tracker (for
    clang-tidy) also triggers a false positive with cppcheck. See here for the
    code snippet https://github.com/llvm/llvm-project/issues/70464

    cppcheck --enable=all repro.cpp

    Checking repro.cpp ...
    repro.cpp:9:4: warning: Member variable 'foo < double >::x' is not
    initialized in the constructor. Maybe it should be initialized directly in
    the class foo < double >? [uninitDerivedMemberVar]
    bar(double x) : foo{x} { }
    ^

    The problem that both clang-tidy and cppcheck appear to trip over is the
    fact that I use a brace initializer in the constructor initializer list of
    a derived class.

    Christian

     
  • CHR

    CHR - 2023-10-31

    Thanks for reporting, fixed by https://github.com/danmar/cppcheck/pull/5606

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.