Re: Please don't do this (code fragment)
Manoj Srivastava <srivasta@debian.org> writes:
> Olaf Weber <olaf@infovore.xs4all.nl> writes:
>> Going back to the original code, the assumption that
>>
>> int i;
>> for (i = 0; i > 0; ++i)
>> ;
>>
>> will terminate, and will terminate within a reasonable amount of time,
>> is not warranted.
>
> Uhh? Am I missing something? The code, as written, terminates
> immediately, without entering the loop. A for loop in C sets the
> initial condition, and *TESTS AT THE TOP*. Since i is initially set
> to 0, the test fails immediately.
That's true of the code quoted, but the real original code had "i > -1".
--
http://www.greenend.org.uk/rjk/
Reply to: