The problem with example 1 is the static_cast. I do find this common pattern with AI generated code. It is much cleaner to construct the variable with the correct type instead of using a static_cast, like char t = type or char t{type}. I actually have an addon that checks for these redundant casts: @cppcheck.checker def RedundantCast(cfg, data): for token in cfg.tokenlist: if not token.variable: continue m = match(token, "%var%@decl ; %var%@assign = static_cast <*>@cast (*) ;") if not m: continue...
In my opinion it can be reverted there was suggestion about reimplementing the goodies in smaller PRs. It cannot be done in smaller PRs, and a new PR will probably be larger in order to address the other issues. I do have follow-up PRs to address the other issues but I am blocked right now as cppcheck wont build and I have PR to fix it which hasn't been merged: https://github.com/danmar/cppcheck/pull/8015(I think this is a must for any release) I would prefer it not be reverted but if it has to be...
Yea I think a 2.11.1 release with this fix would be good, since the the 2.11 release is broken.
Alright, sounds good!
Issue filed: https://trac.cppcheck.net/ticket/11275
It looks like a true positive to me. If ++idx is equal to sizeof(cols)(which is 24) then idx on the previous line if (++col == cols[idx]) would be 23 which is out of bounds since the array has only 3 elements. We could probably improve our analysis to detect this error when doing if (++idx == sizeof(cols)) as well.
This might be related to this issue: https://trac.cppcheck.net/ticket/10783
We seem to have a lot of newer syntaxErrors on daca that should probably be addressed.