MarkOates / blast

0 stars 0 forks source link

Seek out instances of buggy "int < size_t" in for loops #36

Open MarkOates opened 1 year ago

MarkOates commented 1 year ago

Problem

A recent fix to this issue exposed a design flaw in for loops, with int indexes, comparing against a_vector.size() values. Normally this could be fine, but in circumstances where an a_vector element is erased and i-- is decremented on the 0 index value, now we got an issue.

Solution

Comb through the code, locate for loops with this code flaw, and clean them up. You could find them with something like:

$ git grep for | grep "int " | grep size

An example where I did something similar:

-zsh 2023-04-22 11-24-33 png 2023-04-22 16-34-47
MarkOates commented 1 year ago

Consider compiling with warnings/error flags to catch this case. See: https://stackoverflow.com/questions/62689753/why-does-comparison-of-integers-of-different-signs-only-happen-sometimes