Evaluating autoincrements in function calls

chris at mimsy.UUCP chris at mimsy.UUCP
Fri Feb 27 07:40:51 AEST 1987


>In article <4707 at brl-adm.ARPA> welch%UMASS.BITNET at wiscvm.wisc.EDU writes:
>>int    set[]={1,2,3}, i = 0;
>main() {
>printf("\nnumbers in set indexed by incr integer = %d,%d,%d",
>    set[i++], set[i++], set[i++]);
 
[produces different results with different compilers].

In article <3279 at rsch.WISC.EDU> mcvoy at rsch.WISC.EDU (Lawrence W. McVoy) writes:
>This is explicitly undefined in the K&R definition,

And in the ANSI draft standard.

And then in an aside:

>It is unfortunate, though.  Inconsistencies suck.

What inconsistencies?  Those between different compilers?  One must
expect some.  What does the following program, written in ZIFP (zifp
is for pedantry :-) ) do when translated to your favourite Pascal-like
language?

	proc sighed returns program_status <- {
	    var i: integer <- 0;
	    // `set' is a reserved word in this imaginary language
	    var iset: array [integer: 0..2] of integer <- {1, 2, 3};
	    proc f returns integer <- {
		f <- iset[i];
		i <- i + 1;
	    }
	    print("numbers in set: ", f, f, f);
	    sighed <- success;
	}

-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690)
UUCP:	seismo!mimsy!chris	ARPA/CSNet:	chris at mimsy.umd.edu



More information about the Comp.unix.questions mailing list