home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.sgi
- Path: sparky!uunet!pipex!warwick!dcs.warwick.ac.uk!maths.warwick.ac.uk!steve
- From: steve@maths.warwick.ac.uk (Steve Rumsby)
- Subject: Re: gcc2.2.2 on Iris Crimson (HELP!)
- Message-ID: <1992Aug28.124816.12065@dcs.warwick.ac.uk>
- Sender: news@dcs.warwick.ac.uk (Network News)
- Nntp-Posting-Host: severn
- Organization: Geometry Group, Maths Institute, Warwick University, UK.
- References: <TOTSUKA.92Aug27145458@avaia.av.crl.sony.co.jp> <TOTSUKA.92Aug28082940@avaia.av.crl.sony.co.jp>
- Distribution: comp
- Date: Fri, 28 Aug 1992 12:48:16 GMT
- Lines: 62
-
- In article <TOTSUKA.92Aug28082940@avaia.av.crl.sony.co.jp>, totsuka@av.crl.sony.co.jp (Takashi Totsuka) writes:
- > |Same things happens on a R3000 Indigo too. I finally trace the problem
- > |to the hypot function in the C library (SGI's library, not glibc) which
- > |was returning bizarre results, but only after printing a double on cout!
- > |I couldn't see any way that these two functions could interfere with
- > |each other, so I gave up at that point. If anybody has any ideas about
- > |what might be going on, I'd love to hear them.
- > |
- > |As above, this is all compiling libg++-2.2.2 with gcc-2.2.2.
- >
- > I also played aound with Complex::sqrt() and noticed funny return
- > value of hypot() in SGI libm.a.
- >
- Yes, I meant libm, not libc. Slip of the keyboard...
-
- > However, when I check hypot() alone
- > with a simple test program, it just works fine (with native cc and
- > gcc, with -g and -O). On the other hand, it is true that replacing
- > hypot() with its definition (sqrt(x*x + y*y)) fixes the problem.
- >
- > I suspect G++ is doing some unnecessary conversion or it has
- > some problem in procedure call/return...
- >
- No, I don't think so. As I said above, I constructed a C++ program that
- called hypot lots of times, and always got the right answer, *until* I
- put a double on cout, and then hypot always produced the wrong answer.
- Calling printf (also in libg++) with a double is fine and doesn't break
- anything. Try compiling and running this (gcc-2.2.2, libg++-2.2, Irix 4.0.2):
-
- #include <stdio.h>
- #include <iostream.h>
- #include <math.h>
-
- main()
- {
- double x1, x2, x3;
-
- x1 = hypot(1, 0);
- printf("Here's a double from printf %f\n", 4.2);
- x2 = hypot(1, 0);
- cout << "Here's a double via iostream " << 4.2 << "\n";
- x3 = hypot(1, 0);
-
- printf("x1 = %f, x2 = %f, x3 = %f\n", x1, x2, x3);
- }
-
- The results I get are:
-
- Here's a double from printf 4.200000
- Here's a double via iostream 4.2
- x1 = 1.000000, x2 = 1.000000, x3 = 4503599627370497.000000
-
- That value for x3 looks a little suspicious:-)
-
- Can somebody with the source to SGI's hypot (like somebody in SGI maybe:-)
- have a look and see if there's anything an external function can do that
- will break hypot. This is all very strange...
-
- Steve.
- --
- UUCP: ...!uknet!warwick!steve Internet: steve@maths.warwick.ac.uk
- JANET: steve@uk.ac.warwick.maths PHONE: +44 203 524657
-