Path: utzoo!attcan!uunet!lll-winken!sol.ctr.columbia.edu!zaphod.mps.ohio-state.edu!mips!sgi!shinobu!odin!bh From: bh@sgi.com (Bent Hagemark) Newsgroups: comp.sys.sgi Subject: Re: Fun and games with ++ operators Message-ID: <1990Sep28.224937.7838@odin.corp.sgi.com> Date: 28 Sep 90 22:49:37 GMT References: <9009211425.AA04291@snowhite.cis.uoguelph.ca> <1990Sep28.223417.7571@odin.corp.sgi.com> Sender: news@odin.corp.sgi.com (Net News) Organization: Silicon Graphics, Inc., Mountain View, CA Lines: 25 In article <1990Sep28.223417.7571@odin.corp.sgi.com> pkr@sgi.com (Phil Ronzone) writes: >In article <9009211425.AA04291@snowhite.cis.uoguelph.ca> mike@SNOWHITE.CIS.UOGUELPH.CA writes: >> printf("%d %d\n", a[i++], a[i++]); >> Depending on the order of evaluation of function arguments, I would expect >>this code to generate "6 5" or "5 6". But instead it says "5 5", which >>confuses me a bit. Do all pre/post increment/decrement operators only >>take effect after the current source line, or what? I did check the value >>of 'i' on the next line, and it was indeed 2, so that part works. > > >Such behaviour is ill-defined and I thought that K&R had an explicit warning >about it. I.e., don't do that kind of stuff, especially in passing arguments! > > >-- ><----------------------------------------------------------------------------> >Philip K. Ronzone S e c u r e U N I X pkr@sgi.com >Silicon Graphics, Inc. MS 9U-500 work (415) 335-1511 >2011 N. Shoreline Blvd., Mountain View, CA 94039 fax (415) 969-2314 The warning just happens to be on the most important page of K&R C. For the 2nd edition this is page 53. I know this because a copy of it is taped to my office wall right next to my screen! Bent