Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!convex!grogers From: grogers@convex.com (Geoffrey Rogers) Newsgroups: comp.lang.c Subject: Re: DEFINITE bug in Turbo C 2.0 (WHO'S GOT THE BUG????) Message-ID: <100894@convex.convex.com> Date: 27 Mar 90 20:04:54 GMT References: <802@zeusa.UUCP> <946@lectroid.sw.stratus.com> <16259@haddock.ima.isc.com> <1990Mar23.073923.6425@cs.eur.nl> <16269@haddock.ima.isc.com> Sender: news@convex.com Organization: Convex Computer Corporation; Richardson, TX Lines: 25 In article <16269@haddock.ima.isc.com> karl@haddock.ima.isc.com (Karl Heuer) writes: >In article <1990Mar23.073923.6425@cs.eur.nl> reino@cs.eur.nl (Reino de Boer) writes: >>Now, this all depends on the relative precedence of "++" and "*", and >>that is all it should depend on. Please correct me if I'm wrong > >You're wrong. For example, another valid computation of "x = ++a * ++a" is >"r1 = a+1; r2 = a+1; x = r1*r2; ++a; ++a;". The only constraint on the timing >of side effects is that they must take place after the previous sequence point >and before the next one. > >The bottom line is: that code does not produce a well-defined result. Don't >write code like that. I agree with Karl, it is not the compilers that are in error here, it is the code. Also as a side note: x = ++a * ++a; is not ANSI C compliant. The reason it is not, is because you are modifing the same object more then once in the same expression. cheers +------------------------------------+---------------------------------+ | Geoffrey C. Rogers | "Whose brain did you get?" | | grogers@convex.com | "Abbie Normal!" | | {sun,uunet,uiucdcs}!convex!grogers | | +------------------------------------+---------------------------------+