I would expect that Cppcheck 2.14.0 was able to detect this case:
bool someClasss::function([[maybe_unused]] State currentState, [[maybe_unused]] State pendingState) { return true; < rest of code with multiple returns> }
This works:
bool someClasss::function([[maybe_unused]] State currentState, [[maybe_unused]] State pendingState) { return true; g(); return false; }
foo.cpp:4:5: style: Statements following 'return' will never be executed. [unreachableCode] g(); ^
It's indeed a bit more funcy ;)
It does detect a function call and a switch statement, but not an if-statement. This is detected:
{ return true; somefunc(); return false; }
But this is not:
{ return true; if (State == ERROR) { return true; } return false; }
also an if(true) is not detected.
Probably covered by https://trac.cppcheck.net/ticket/12326 or https://trac.cppcheck.net/ticket/12244
Log in to post a comment.
I would expect that Cppcheck 2.14.0 was able to detect this case:
This works:
It's indeed a bit more funcy ;)
It does detect a function call and a switch statement, but not an if-statement.
This is detected:
{
return true;
somefunc();
return false;
}
But this is not:
also an if(true) is not detected.
Last edit: Rob Deckers 2024-06-06
Probably covered by https://trac.cppcheck.net/ticket/12326 or https://trac.cppcheck.net/ticket/12244