From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: From: David Presotto To: 9fans@cse.psu.edu Subject: Re: [9fans] remember when C compiler used to produce working code? i don't! In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="upas-uzwcmcyjtsumgjhbbncfuhfrcb" Date: Fri, 30 Jan 2004 17:29:21 -0500 Topicbox-Message-UUID: c8405784-eacc-11e9-9e20-41e7f4b1d025 This is a multi-part message in MIME format. --upas-uzwcmcyjtsumgjhbbncfuhfrcb Content-Disposition: inline Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit It does work if you replace: elasticity *= ratio; with elasticity = elasticity * ratio; Clearly we're analyzing wrong when there's only an assignment. --upas-uzwcmcyjtsumgjhbbncfuhfrcb Content-Type: message/rfc822 Content-Disposition: inline Received: from plan9.cs.bell-labs.com ([135.104.9.2]) by plan9; Fri Jan 30 17:06:38 EST 2004 Received: from mail.cse.psu.edu ([130.203.4.6]) by plan9; Fri Jan 30 17:06:35 EST 2004 Received: by mail.cse.psu.edu (CSE Mail Server, from userid 60001) id 03E6F19B68; Fri, 30 Jan 2004 17:06:29 -0500 (EST) Received: from psuvax1.cse.psu.edu (psuvax1.cse.psu.edu [130.203.4.6]) by mail.cse.psu.edu (CSE Mail Server) with ESMTP id 464DA19CAF; Fri, 30 Jan 2004 17:06:14 -0500 (EST) X-Original-To: 9fans@cse.psu.edu Delivered-To: 9fans@cse.psu.edu Received: by mail.cse.psu.edu (CSE Mail Server, from userid 60001) id 02E6019B68; Fri, 30 Jan 2004 17:05:57 -0500 (EST) Received: from plan9-2.ucalgary.ca (fbsd.cpsc.ucalgary.ca [136.159.7.68]) by mail.cse.psu.edu (CSE Mail Server) with ESMTP id 07FFA19C8E for <9fans@cse.psu.edu>; Fri, 30 Jan 2004 17:05:46 -0500 (EST) Message-ID: To: 9fans@cse.psu.edu From: andrey mirtchovski MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: [9fans] remember when C compiler used to produce working code? i don't! Sender: 9fans-admin@cse.psu.edu Errors-To: 9fans-admin@cse.psu.edu X-BeenThere: 9fans@cse.psu.edu X-Mailman-Version: 2.0.11 Precedence: bulk Reply-To: 9fans@cse.psu.edu List-Id: Fans of the OS Plan 9 from Bell Labs <9fans.cse.psu.edu> List-Archive: Date: Fri, 30 Jan 2004 15:05:43 -0700 X-Spam-Status: No, hits=0.7 required=5.0 tests=PLING_QUERY version=2.55 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.55 (1.174.2.19-2003-05-19-exp) I got bitten by this one pretty hard today, took me the better part of the day to find out... The 'elasticity *= ratio' code comes from the XScreensaver distribution and was written sometime in 1997, so presumably this has been working since then (and braking when compiled with 8c?). In Plan 9 the following code produces 800/0: plan9-2% cat t.c #include #include main() { long elasticity = 8000L; double ratio = 0.1; /* this is fine */ elasticity = (long)(((double)elasticity)*ratio); print("%ld\n", elasticity); /* this breaks with 8c */ elasticity *= ratio; print("%ld\n", elasticity); } plan9-2% 8c t.c; 8l t.8 plan9-2% 8.out 800 0 plan9-2% Its (almost) identical lunix counterpart, when compiled with gcc 3.2, produces 800/80: mirtchov@fbsd$ cat t.c main() { long elasticity = 8000L; double ratio = 0.1; /* this is fine */ elasticity = (long)(((float)elasticity)*ratio); printf("%ld\n", elasticity); /* this if fine with gcc 3.2 */ elasticity *= ratio; printf("%ld\n", elasticity); } mirtchov@fbsd$ gcc t.c mirtchov@fbsd$ ./a.out 800 80 mirtchov@fbsd$ Not looking to assign any blame, just letting you know... andrey --upas-uzwcmcyjtsumgjhbbncfuhfrcb--