From: David Presotto <presotto@closedmind.org>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] remember when C compiler used to produce working code? i don't!
Date: Fri, 30 Jan 2004 17:40:57 -0500 [thread overview]
Message-ID: <20f6c2bf812efc23f83f7fc5e8d4634d@plan9.bell-labs.com> (raw)
In-Reply-To: <d68515d6a85237b56c150190c4ac45d0@plan9.bell-labs.com>
[-- Attachment #1: Type: text/plain, Size: 174 bytes --]
Looks like a problem in cc/com.c in tcomo(). I'm going to be away
for a week and will take a crack at it when I get back. If someone
else wants to try in the mean time...
[-- Attachment #2: Type: message/rfc822, Size: 5303 bytes --]
[-- Attachment #2.1.1: Type: text/plain, Size: 180 bytes --]
It does work if you replace:
elasticity *= ratio;
with
elasticity = elasticity * ratio;
Clearly we're analyzing wrong when there's only an assignment.
[-- Attachment #2.1.2: Type: message/rfc822, Size: 3015 bytes --]
From: andrey mirtchovski <mirtchov@cpsc.ucalgary.ca>
To: 9fans@cse.psu.edu
Subject: [9fans] remember when C compiler used to produce working code? i don't!
Date: Fri, 30 Jan 2004 15:05:43 -0700
Message-ID: <d45fb131231fd5a3515e0f7518a6568a@plan9.ucalgary.ca>
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 <u.h>
#include <libc.h>
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
next prev parent reply other threads:[~2004-01-30 22:40 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-01-30 22:05 andrey mirtchovski
2004-01-30 22:29 ` David Presotto
2004-01-30 22:40 ` David Presotto [this message]
2004-01-31 0:57 ` Bruce Ellis
2004-01-31 1:34 ` boyd, rounin
2004-01-31 1:51 ` Bruce Ellis
2004-01-31 2:15 ` boyd, rounin
2004-01-31 3:13 ` David Presotto
2004-01-31 7:40 ` Bruce Ellis
2004-01-31 9:03 ` andrey mirtchovski
2004-01-31 10:08 ` David Tolpin
2004-01-31 14:19 ` boyd, rounin
2004-01-31 14:57 ` Bruce Ellis
2004-01-31 17:59 ` Scott Schwartz
2004-01-31 19:23 ` Rob Pike
2004-01-31 19:59 ` Bruce Ellis
2004-01-31 20:42 ` Charles Forsyth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20f6c2bf812efc23f83f7fc5e8d4634d@plan9.bell-labs.com \
--to=presotto@closedmind.org \
--cc=9fans@cse.psu.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).