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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'd appreciate if someone would look into this warning and raise a ticket if appropriate.
It looks to be a bug to me give a trivial change in the code avoids it (see comments below).
It looks like a true positive to me. If
++idxis equal tosizeof(cols)(which is24) thenidxon the previous lineif (++col == cols[idx])would be23which 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.Darn you're right - thanks for the feedback.
I guess even after reducing it to a simpler example, I just too focussed on the problem to see that it was using sizeof instead of std::size.
Last edit: Andrew 2022-08-21