Found in 2.10
#include <iostream> #include <array> std::array<int, 1> foo; std::array<int, 1> bar; int main() { foo[0] = 0; bar[0] = 0; const auto& ints = foo; std::cout << (ints == bar); return 0; }
Output:
$ cppcheck --std=c++17 --enable=all --platform=win64 cppcheck_false_positives.cpp Checking cppcheck_false_positives.cpp ... cppcheck_false_positives.cpp:15:15: style: Variable 'ints' can be declared as pointer to const [constVariable] const auto& ints = foo; ^
Thanks for reporting, fixed by https://github.com/danmar/cppcheck/pull/4777
Log in to post a comment.
Found in 2.10
Output:
Last edit: Dan Workman 2023-02-07
Thanks for reporting, fixed by https://github.com/danmar/cppcheck/pull/4777