Path: utzoo!attcan!uunet!mcvax!hp4nl!botter!star.cs.vu.nl!maart From: maart@cs.vu.nl (Maarten Litmaath) Newsgroups: comp.lang.c Subject: Re: Does your compiler get this program right? Keywords: float, increment Message-ID: <1703@solo9.cs.vu.nl> Date: 24 Nov 88 18:57:25 GMT References: <2298@cbnews.ATT.COM> <4082@cs.utexas.edu> Reply-To: maart@cs.vu.nl (Maarten Litmaath) Organization: VU Informatica, Amsterdam Lines: 33 In article <4082@cs.utexas.edu> meyering@cs.utexas.edu (Jim Meyering) writes: \In article <2298@cbnews.ATT.COM> lvc@cbnews.ATT.COM (Lawrence V. Cipriani) writes: \ >A friend of mine found a bug in his C compiler. He found \ \It's not a bug. It IS a bug! \ [...deleted commentary, code] \ >*f++ += *g++; /* miscompiled line */ \ \The standard does not specify the order of evaluation for such \statements. There is NO problem concerning evaluation order! Remember: `a += b' means `a = a + b, BUT evaluate a only ONCE!' \... \ *f += *g++; or *f = *f + *g++; \ f++; f++; \ \I found that the size of the object code was actually reduced. \Chalk one up for readability *and* efficiency. Readability? Hahaha! No, really :-( `*f++ += *g++' is perfectly readable and valid C. It's constructs like this one that make C as powerful as it is. Are you a Pascal or Modula freak? Consider `LongVariableName = LongVariableName + 3': do you find this gem more readable? More typable? If there are side effects, you cannot even use the `Pascal construct'. -- fcntl(fd, F_SETFL, FNDELAY): |Maarten Litmaath @ VU Amsterdam: let's go weepin' in the corner! |maart@cs.vu.nl, mcvax!botter!maart