Path: utzoo!utgpu!water!watmath!rbutterworth From: rbutterworth@watmath.waterloo.edu (Ray Butterworth) Newsgroups: comp.lang.c Subject: Another way (How not to write a loop) Message-ID: <16941@watmath.waterloo.edu> Date: 15 Feb 88 15:09:15 GMT References: <560@naucse.UUCP> <1988Feb11.200149.25172@sq.uucp> <2115@bsu-cs.UUCP> Organization: U of Waterloo, Ontario Lines: 17 I just got hit by yet another way not to write a loop: auto size_t index; index = sizeof(array) / sizeof(array[0]); while (--index >= 0) blah blah blah This looks wonderfully portable and works fine on the BSD 4.3 compiler (and probably most others). But on an ANSI compiler, (size_t) will be an unsigned integer and the loop will go forever. Lint will notice this problem, but only with the ANSI compiler when it is probably too late.