public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c/5277: NaN unexpectedly
@ 2002-11-05 7:59 bangerth
0 siblings, 0 replies; 3+ messages in thread
From: bangerth @ 2002-11-05 7:59 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, long, nobody
Synopsis: NaN unexpectedly
State-Changed-From-To: open->closed
State-Changed-By: bangerth
State-Changed-When: Tue Nov 5 07:59:10 2002
State-Changed-Why:
Reporter states that this was his error.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=5277
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: c/5277: NaN unexpectedly
@ 2002-01-06 10:36 Knox S. Long
0 siblings, 0 replies; 3+ messages in thread
From: Knox S. Long @ 2002-01-06 10:36 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR c/5277; it has been noted by GNATS.
From: "Knox S. Long" <long@stsci.edu>
To: gcc-gnats@gcc.gnu.org, gcc-prs@gcc.gnu.org, long@stsci.edu,
gcc-bugs@gcc.gnu.org
Cc:
Subject: Re: c/5277: NaN unexpectedly
Date: Sun, 06 Jan 2002 13:33:49 -0500
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=5277
Mea culpa! I now understand the cause of this problem and I don't know whether it
is a bug or not. In all of the cases in which this problem appeared, it was in
a function which had been declared as a double, e.g.
double
thierry_velocity (x, v)
double x[];
double v[];
{
int n; ...
In this particular case what was being calculated was a velocity v from a position
x. The routine was returning the speed, which is simply a double precision number.
In this and all of the other cases where I observed this problem, the routine had
not been declared as a double in the calling routine (since I was not actually
interested in the returned value). Once this was done the program, all spurious
instances on Nan disappeared.
I have no idea of course whether this is the expected performance of gcc, though
certainly the problem is not dire for me if it is. It was lesson to me to use
-Wall on anything I really seriously care about.
I apologize to anyone this has inconvenienced.
Sincerely,
Knox Long
^ permalink raw reply [flat|nested] 3+ messages in thread
* c/5277: NaN unexpectedly
@ 2002-01-04 11:06 long
0 siblings, 0 replies; 3+ messages in thread
From: long @ 2002-01-04 11:06 UTC (permalink / raw)
To: gcc-gnats
>Number: 5277
>Category: c
>Synopsis: NaN unexpectedly
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Jan 04 11:06:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: Knox S. Long
>Release: gcc-2.96-81
>Organization:
>Environment:
Redhat 7.1 (on a Dell Dimension 1 Ghz machine)
glibc-2.2.4-19.3
>Description:
I am seeing a problem in which simple double precision math
occasionally generates NAN problems. The probalem is odd
because if on printf's the offending variable, and reprints
the result, the NAN problem goes away
Here is an example code fragement where this can occur.
double
thierry_velocity (x, v)
double x[];
double v[];
{
int n;
double r, speed;
double frac,z;
double length ();
z=x[0]*x[0]+x[1]*x[1]+x[2]*x[2];
if(sane_check(z)){
printf("%f\n",z);
z=x[0]*x[0]+x[1]*x[1]+x[2]*x[2];
printf("%f\n",z);
}
r = length (x);
...
where sane_check simply checks to see whether x is finite, e.g.
int
sane_check (x)
double x;
{
int i;
if ((i = finite (x)) == 0)
{
Error ("sane_check: %d %e\n", i, x);
return (-1);
}
return (0);
}
There was some discussion of a similar problem on the web
associated with gcc 2.95.1. and even a reference to a bug
report which I could not locate.
I ran the identical program on a Sun (with gcc 2.95) and
did not see the problem.
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-11-05 15:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-05 7:59 c/5277: NaN unexpectedly bangerth
-- strict thread matches above, loose matches on Subject: below --
2002-01-06 10:36 Knox S. Long
2002-01-04 11:06 long
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 read-only IMAP folder(s) and NNTP newsgroup(s).