Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!necntc!ima!johnl From: johnl@ima.ISC.COM (John R. Levine) Newsgroups: comp.lang.c Subject: Re: another auto-increment problem Message-ID: <723@ima.ISC.COM> Date: Sat, 26-Sep-87 17:12:54 EDT Article-I.D.: ima.723 Posted: Sat Sep 26 17:12:54 1987 Date-Received: Sun, 27-Sep-87 11:21:38 EDT References: <3680001@wdl1.UUCP> Reply-To: johnl@ima.UUCP (John R. Levine) Organization: Not enough to make any difference Lines: 26 Summary: famous point of confusion In article <3680001@wdl1.UUCP> rion@wdl1.UUCP (Rion Cassidy) writes: > ... > float junk[3], *junk_ptr; > ... > junk_ptr = (float *) junk; > xfpt(*junk_ptr++, *junk_ptr++, *junk_ptr); > [isn't the same as] > xfpt(junk[0], junk[1], junk[2]); Two points. First, as has been pointed out elsewhere, no version of C has ever made any promises about the order of evaluation of arguments nor of side effects. It would be entirely legitimate for the compiler in the first case to push junk[0] three times and then increment the pointer twice, and on many machines that'd be the best code. Second, on computers that don't have auto-increment address modes, the second version is probably faster and smaller than the first, not to mention making your intentions clearer. In any event, one or two extra address calculation instructions are unlikely to make any perceptible difference if the called routine is going to do a bunch of floating point multiplication. Make it right, then make it fast. -- John R. Levine, IECC, PO Box 349, Cambridge MA 02238-0349, +1 617 492 3869 { ihnp4 | decvax | cbosgd | harvard | yale }!ima!johnl, Levine@YALE.something The Iran-Contra affair: None of this would have happened if Ronald Reagan were still alive.