register variable???

D'Arcy Cain darcy at bbm.UUCP
Tue Sep 12 03:29:19 AEST 1989


In article <30585 at srcsip.UUCP> sklee at srcsip.UUCP () writes:
>  while (i < 4)  list[i] = list[++i];
I have always been too scared to take a chance on this type of code.  It
seems to me that it is subject to compiler interpretation as to when the
++ operator is applied.  Example on the first iteration:

    list[0] = list[1];
or
    list[1] = list[1];

I don't actually know if either is guaranteed by some standard but even
if it is I wouldn't want to depend on such a guarantee on a specific
compiler having seen how some of them implement "standards".  I would
use the following replacement for the above line:

	for (i = 0; i < 4; i++) list[i] = list[i + 1];
which keeps the increment out of the loop.

D'Arcy J.M. Cain
(darcy at bbm, darcy at cain)



More information about the Comp.lang.c mailing list