I have recently started using the -Wall compiler switch in an attempt to improve the quality of my code. It is giving (correctly) a warning about this little snippet...
int i;
for (i = start - 1; i >= 0; i--)
{
if (i >= number1.array.size())
{
one_value = 0;
}
because number1.array.size is unsigned (it's the size method on a std::vector). Since the test in the loop is i >= 0, i has to be signed or it doesn't work. It seems I have three choices; to refrain from using -Wall, to ignore the warning, or to introduce an ancillary element...
int i;
unsigned int j;
for (i = start - 1; i >= 0; i--)
{
j = i;
if (j >= number1.array.size())
{
one_value = 0;
}
None of these seems particularly desirable. Can you suggest any alternative, or make a recommendation as to what I should do in this case?