Return to BSD News archive
Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!news.mel.connect.com.au!munnari.OZ.AU!news.ecn.uoknor.edu!feed1.news.erols.com!howland.erols.net!news.mathworks.com!fu-berlin.de!irz401!orion.sax.de!uriah.heep!news From: j@uriah.heep.sax.de (J Wunsch) Newsgroups: comp.unix.bsd.freebsd.misc Subject: Re: Compiler bug? Date: 8 Dec 1996 15:17:56 GMT Organization: Private BSD site, Dresden Lines: 25 Message-ID: <58em74$me3@uriah.heep.sax.de> References: <55tf99$6b5@garuda.synet.net> <57hsae$cpm@uwm.edu> <57l5t1$hr0@uriah.heep.sax.de> <57vt85$top@uwm.edu> Reply-To: joerg_wunsch@uriah.heep.sax.de (Joerg Wunsch) NNTP-Posting-Host: localhost.heep.sax.de Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Newsreader: knews 0.9.6 X-Phone: +49-351-2012 669 X-PGP-Fingerprint: DC 47 E6 E4 FF A6 E9 8F 93 21 E0 7D F9 12 D6 4E bacon@alpha1.csd.uwm.edu (Jason Wayne Bacon) wrote: > >There are only two exceptions in C where the standard requires a > >particular sequence of evaluation: the comma operator (obvious), and > >the && and || operators (so you can say ``if (ptr && *ptr ...)''). > >For everything else, only the associativity is defined. > > Yeah, and it's too bad. The C standard probably should > define the order of evaluation in these cases to avoid ambiguity. I believe it has been deliberately left implentation-dependant, with the couple of exceptions above. This way, the compiler can optimize it the way it fits best for a particular architecture. Remember that the prefix and postfix increment and decrement operators have certainly been inspired by the PDP-11's ability to implement x++ and --x directly by the CPU. Forcing a compiler to not use such features of a particular CPU (by explicitly requiring a particular order of evaluation) can waste a fair amount of optimization opportunities. -- cheers, J"org joerg_wunsch@uriah.heep.sax.de -- http://www.sax.de/~joerg/ -- NIC: JW11-RIPE Never trust an operating system you don't have sources for. ;-)