Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!convex!sushi!grogers From: grogers@sushi.uucp (Geoffrey Rogers) Newsgroups: comp.lang.c Subject: Re: ambiguous ? Message-ID: <2120@convex.UUCP> Date: 16 Oct 89 20:00:35 GMT References: <20974@gryphon.COM> Sender: news@convex.UUCP Reply-To: grogers@sushi.UUCP (Geoffrey Rogers) Organization: Convex Computer Corporation, Richardson, Tx. Lines: 25 In article <20974@gryphon.COM> bagpiper@pnet02.gryphon.com (Michael Hunter) writes: >In the following code fragment is line 3 ambiguous from an X3J11 standpoint >or from a historical standpoint. > >1) int Ret ; >2) >3) func(Ret = func2(), Ret+30) ; > >I wouldn't normally write code like this, but I ran across code similar to >this in a program I am maintaining, and, as long as it isn't ambigous to some >large subset of the existing compilers, I will probably leave it be. > In both K&R I and pANSI C the evaulation order of parameters being pass to a function is undefined. This means that if you compile the above code with two different compilers you could get two different answers! You should rewrite the code as follows: 1) int Ret ; 2) 3) Ret = func2() ; 4) func(Ret, Ret+30) ; Geoffrey C. Rogers