Search code examples
c++c++11boostcppcheck

cppcheck reports "Redundant code: Found a statement that begins with numeric constant" for a 'using' statement


Understanding that this is not a ton of context, I have this line:

using GridType = Grid<boost::optional<float>, 2>;

for which cppcheck says:

Redundant code: Found a statement that begins with numeric constant.

I would think "false positive", but usually these analysis tools are smarter than me, so I wanted to check if anyone can think of why a statement like this could be interpreted like that by the analyzer?

I'm using cppcheck 1.61 on a Ubuntu system.


Solution

  • cppcheck is largely based on pattern matching and is not too smart / quite shallow at times. It does find a bunch of nice stuff but also has a lot of false positives. I'd say this is a false positive where cppchecks simple mind got confused.

    Also; version 1.61 is a bit old. Have you tested the latest 1.74 to see if it is more clever here? (It's quite simple to build from source if it is not in your distributions repository)