register variable???

Perry Hutchison perry at ccssrv.UUCP
Wed Sep 13 11:54:50 AEST 1989


In article <19487 at mimsy.UUCP> chris at mimsy.UUCP (Chris Torek) writes:

> In article <30585 at srcsip.UUCP> sklee at pompeii.SRC.Honeywell.COM (Sungkee Lee)
> writes:
> >  while (i < 4)  list[i] = list[++i];
> 
> USE LINT!!!!!
> 
> Sheesh.

Provided he has it on his system and understands the (frequently cryptic)
messages it produces.  Let's answer the fellow's question:

The assignment produces "undefined results" because there is no guarantee
as to when "side effects" (like ++) happen.  According to the definition
of prefix ++, the right-hand operand of = must use the incremented value of
i as the subscript; however the left-hand operand may evaluate the address
into which the assignment will take place either before or after the right-
hand expression stores the incremented value into i.  It appears that, in
this implementation, that decision is different depending on whether i is
a register variable.



More information about the Comp.lang.c mailing list