Article View: gnu.gcc.bug
Article #770?absv bug? (goes away with debugging cout)
From: piggy
Date: Mon, 30 Oct 1989 19:03
Date: Mon, 30 Oct 1989 19:03
70 lines
2260 bytes
2260 bytes
------- Forwarded Message
Received: by gargoyle.uchicago.edu from tartarus.uchicago.edu (5.59/1.14)
id AA18981; Thu, 26 Oct 89 16:47:36 198
Received: by tartarus.uchicago.edu (4.0/4.7)
id AA15018; Thu, 26 Oct 89 16:49:06 CDT
Date: Thu, 26 Oct 89 16:49:06 CDT
From: keenan@tartarus.UChicago.EDU (Philip Keenan)
Message-Id: <8910262149.AA15018@tartarus.uchicago.edu>
To: bugs@tartarus.uchicago.edu
Subject: Another bug in GNU C++
Cc: keenan@tartarus.uchicago.edu
Here is another bug you can forward to the GNU people. It is an
especially nasty and subtle one, where something internal has
the wrong value, but when you print the value to check, the act
of printing gets rid of the bug, so it prints the correct value,
leaving you to wonder why it fails when you comment out the print line!
- -- Phil Kenan
***************************************************************
/* bug.cc
Phil Keenan 10-25-89.
This short program illustrates a bug in GNU C++ v. 1.35.1-
As it stands, it produces as output "0" and "1", which is incorrect.
They should both be "1".
If you simply uncomment the commented out line in function complex::cabsv(),
it does compute them correctly.
*/
#include <stream.h>
double absv(double d) { if(d>=0) return d; else return -d; }
struct complex {
double r, i;
complex(double re=0, double im=0) { r=re; i=im; }
double cabsv();
};
double complex::cabsv()
{
double x,y;
x = absv(r);
y = absv(i);
// cout << x << " " << y << "\n";
if(x==0.0) return y;
if(y==0.0) return x;
return 100;
}
void main()
{
complex e;
e = complex(0,1);
cout << e.cabsv() << "\n";
e = complex(1,0);
cout << e.cabsv() << "\n";
}
***************************************************************
The end.
------- End of Forwarded Message
Technical Details
Message-ID:
<8910301903.AA06746@gargoyle.uchicago.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!GARGOYLE.UCHICAGO.EDU!piggyShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!GARGOYLE.UCHICAGO.EDU!piggy From: piggy@GARGOYLE.UCHICAGO.EDU Newsgroups: gnu.gcc.bug Subject: ?absv bug? (goes away with debugging cout) Message-ID: <8910301903.AA06746@gargoyle.uchicago.edu> Date: 30 Oct 89 19:03:32 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 70