Evaluating autoincrements in function calls

black at ee.UCLA.EDU black at ee.UCLA.EDU
Fri Feb 27 10:47:33 AEST 1987


> numbers in set indexed by incr integer = 3,2,1
> numbers in set indexed by constants = 1,2,3

I recall having this happen once.  Actually, it never 'happened';
I caught it before it was a bug (in the larval stage, one could say :=)).
A pass from lint caught it and said, "Order of evaluation unspecified."

If you look at "The Bible" (K&R C), page 192, you will see that
the comma operator does not really apply to this case.  Furthermore,
K&R, page 50, states a case almost exactly like yours and concludes:
"...writing code which depends on order of evaluation is bad..."

Caveat hacker!

Rex Black

black at ee.ucla.edu                                          ARPA        
...!{ihnp4,ucbvax,sdcrdcf,trwspp}!ucla-cs!uclaee!black     UUCP

Disclaimer:  No offense intended.



More information about the Comp.unix.questions mailing list