Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site mit-eddie.UUCP Path: utzoo!linus!security!genrad!mit-eddie!mp From: mp@mit-eddie.UUCP (Mark Plotnick) Newsgroups: net.lang.c Subject: ++ operator Message-ID: <1092@mit-eddie.UUCP> Date: Sun, 25-Dec-83 17:30:47 EST Article-I.D.: mit-eddi.1092 Posted: Sun Dec 25 17:30:47 1983 Date-Received: Mon, 26-Dec-83 04:10:07 EST References: <122@taurus.UUCP> Organization: MIT, Cambridge, MA Lines: 27 dave@taurus notes: Uh-uh: if(*in++ == *in++) ... Also, for those of little faith, there are actually C compilers that will take the non-obvious meaning of this (e.g. the PDP-11 cc), and do the tests then do both increments in one go after the statement, so BE WARNED. I just tried this with the V7 cc, 4.1bsd pcc, and VAX-11 C compilers, and in each case two increments were done. The reference manual is vague here, but a good rule of thumb is that foo++ is equivalent to ((foo=foo+1)-1). I don't know of any exceptions to this off-hand, although I heard that a pcc author was once thinking of delaying the postincrement of function args until after the function call [i.e. f(i++) would be equivalent to (temp=f(i),i++,temp) ]. Since there are still quite a few C compilers being written from scratch out there, it would really help if someone were to come up with a precise, consistent definition for how the postincrement and postdecrement operators should behave. Ditto for enum, void, unsigned chars, non-integer bitfields, etc. Mark