Theory of Pure C, chapter 937

utzoo!decvax!cca!ima!johnl utzoo!decvax!cca!ima!johnl
Mon Dec 20 15:35:00 AEST 1982

Consider the following code fragment:

int x;  /* global definition */
	if(x == oldx) ...

Does bar see the old value of x or the new value?  The C Reference Manual
sheds little light.  It says that "After the result is noted, the object
is incremented ...."  One might claim that it's indeterminate, but a case
could be made that the value has to be noted before the call happens, so
the incrementation should happen, too.  Lint doesn't complain about this,
by the way.

In practice, anybody who does this sort of thing gets what he (it?)
deserves, but arguing is always fun.

Reply to me, if you must.

John Levine, decvax!yale-co!jrl, ucbvax!cbosgd!ima!johnl, Levine at YALE (arpa).

PS:  This reminds me of the problems of recursive I/O that snuck into
Fortran when general expressions were allowed as subscripts, since you
could put a function call into a subscript expression in an I/O list and
have I/O in the function.  Urrgh.


More information about the Comp.lang.c mailing list