Evaluating autoincrements in function calls

mcvoy at uwvax.UUCP mcvoy at uwvax.UUCP
Fri Feb 27 05:02:49 AEST 1987


In article <4707 at brl-adm.ARPA> welch%UMASS.BITNET at wiscvm.wisc.EDU writes:
->In the second case the compiler is evaluating the arguments to
->the printf function right to left, including the autoincrement
->instructions, as it builds the stack.
-> 
->I don't want to be swamped with replies as to which set of results
->is correct but I would be interested to know if there is a standard
->which documents the correct behavior of argument evaluation.

This is explicitly undefined in the K&R definition, in other words, you
may not depend on any order of evalualtion when considering function
parameters.  My guess is that it was done as a efficiency/favour
for/to compilers/{compiler writers}.  Functions are done a lot;
it would be ill-advised to slow them down by enforcing evaluation
orders here.  It is unfortunate, though.  Inconsistencies suck.
-- 
Larry McVoy 	        mcvoy at rsch.wisc.edu, 
      		        {seismo, topaz, harvard, ihnp4, etc}!uwvax!mcvoy

"They're coming soon!  Quad-stated guru-gates!"



More information about the Comp.unix.questions mailing list