Using the latest commit (71d386819e70ea13fbd6d1a5be073ad8fe05cff6), the following code triggers an error, despite the only possible codepath returning a value:
Can't you remove the if (...), since you already have the assert?
That is definitely possible here. But in the real code this example is based on, there was a long chain of if - else if - else if. The last else if could be replaced by simple else there too, but it's debatable which approach is more readable.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Using the latest commit (71d386819e70ea13fbd6d1a5be073ad8fe05cff6), the following code triggers an error, despite the only possible codepath returning a value:
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/11204
Can't you remove the
if (...)
, since you already have the assert?Thanks!
That is definitely possible here. But in the real code this example is based on, there was a long chain of
if
-else if
-else if
. The lastelse if
could be replaced by simpleelse
there too, but it's debatable which approach is more readable.