Found in 2.9 and 2.10
#include <iostream> #include <optional> struct Result { bool isValid{false}; }; std::optional<Result> GetResult() { return Result{true}; } int main() { auto res = GetResult(); if (res.has_value()) std::cout << res->isValid; return 0; }
Output:
$ cppcheck --std=c++17 --enable=all --platform=win64 cppcheck_false_positives.cpp Checking cppcheck_false_positives.cpp ... cppcheck_false_positives.cpp:8:8: style: struct member 'Result::isValid' is never used. [unusedStructMember] bool isValid{false}; ^
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/11539
Log in to post a comment.
Found in 2.9 and 2.10
Output:
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/11539