Path: utzoo!mnetor!uunet!husc6!mit-eddie!uw-beaver!cornell!rochester!PT.CS.CMU.EDU!cadre!pitt!darth!investor!rbp From: rbp@investor.UUCP (Bob Peirce) Newsgroups: comp.lang.c Subject: Re: Is this a bug, or is it just me? Message-ID: <881@investor.UUCP> Date: 22 Dec 87 19:58:44 GMT References: <464@ecrcvax.UUCP> Organization: Cookson, Peirce & Co., Pittsburgh, PA Lines: 27 > I think I have found a problem. I know that operations of the same > precedence can be reordered by the compiler, but I wouldn't think that > all three auto-increments would be done after all the additions. This > happens on both a vax (4.3bsd) and a Sun-3. > > #include > > int sum = 0; > int a[3] = {1, 4, 16}; > int i = 0; > > main () { > sum = a[i++] + a[i++] + a[i++]; > printf ("sum: %d i:%d\n", sum, i); > } > > Results in: > sum: 3 i:3 > > John Gregor > johng%ecrcvax.UUCP@germany.CSNET I get "sum: 21 i:3" on an Altos 3068 (M68020). -- Bob Peirce, Pittsburgh, PA 412-471-5320 uucp: ...!{allegra, bellcore, cadre, idis, psuvax1}!pitt!investor!rbp NOTE: Mail must be < 30K bytes/message