Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!cbosgd!gatech!seismo!rochester!gardner From: gardner@rochester.ARPA (Paul Gardner ) Newsgroups: net.lang.c Subject: Re: *p++ = *p and more Message-ID: <16634@rochester.ARPA> Date: Thu, 27-Mar-86 14:28:00 EST Article-I.D.: rocheste.16634 Posted: Thu Mar 27 14:28:00 1986 Date-Received: Sat, 29-Mar-86 04:33:12 EST References: <357@g.cs.cmu.edu> Organization: U of Rochester, CS Dept., Rochester, NY Lines: 25 In article <357@g.cs.cmu.edu>, ckk@g.cs.cmu.edu (Chris Koenigsberg) writes: > The question was "what does (*p++ = *p) do?" > The answer was that it could give one of two results, and both were legal > since the value is undefined, depending on whether the compiler decides to > increment before or after the fetch of the rvalue. > > We ran into a similar problem with a section of code containing > "i=0; while(i and we found that the Sun 120 4.2 C compiler decided that a[0] gets b[1], > while the IBM RT PC ACIS 4.2 C compiler decided that a[1] gets b[1] and a[0] > gets nothing (remains null, if it was initialized this way). Are you sure that's the way it happens? Assuming that the "a[i] = b[i++]" is just ambiguous and not wrong (this seems to be the consensus anyway) then either we index into a[] first or we index into b[] and increment i first. In the first case a[0] gets b[0] and i == 1 after the assignment. In the second case a[1] gets b[0] and i == 1 after the assignment. In any case the results you mention make no sense when the postfix ++ is used. Perhaps you meant: "i=0; while(i