int j;
for (j = 1; 0 < j; j *= 2)
if (! bigtime_test (j))
return 1;
Here it is obvious to a programmer that the comparison is
intended to do overflow checking, even though the test
controls the loop.
Well, it's not to me. :-)
Another question for the GCC experts: would it fix the bug
if we replaced "j *= 2" with "j <<= 1" in this sample code?
Yes, it will actually compile the code as this:
int i, j;
for (i = 0, j = 1; i < 31; i++)
j <<= 1;
Or you can do, since elsewhere in the code you compute time_t_max:
for (j = 1; j <= time_t_max / 2 + 1; j *= 2)
Which is IMO more intention revealing.
Paolo