(Not sure how to register on Trac, so I'm posting this bug report here.)
I started a new project and I'm free to require C++17, so am using all language features at will without restrictions. But I ran into an annoying false positive that is guaranteed to occur every time I do something similar to this:
if (auto it = items.find(key); it != items.end()) {
// can safely use 'it'
} else {
// not found
}
cppcheck 1.88 always wrongly reports:
Suspicious condition. The result of find() is an iterator, but is not properly checked.
The non-initializer equivalent of the above code does not generate the false positive.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
(Not sure how to register on Trac, so I'm posting this bug report here.)
I started a new project and I'm free to require C++17, so am using all language features at will without restrictions. But I ran into an annoying false positive that is guaranteed to occur every time I do something similar to this:
cppcheck 1.88 always wrongly reports:
The non-initializer equivalent of the above code does not generate the false positive.
Thanks! I created this ticket: https://trac.cppcheck.net/ticket/9237