The following code is happily accepted by g++-10 and clang++-15, yet cannot be parsed by cppcheck.
It seems that float_ptr(b.data()) is interpreted as float * (b.data()), which is indeed incorrect, because float_ptr should be treated as a single token. Rewriting the offending statement as (float_ptr)(b.data()) solves the problem.
The following code is happily accepted by g++-10 and clang++-15, yet cannot be parsed by cppcheck.
It seems that
float_ptr(b.data())
is interpreted asfloat * (b.data())
, which is indeed incorrect, becausefloat_ptr
should be treated as a single token. Rewriting the offending statement as(float_ptr)(b.data())
solves the problem.Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/11430