public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: long@stsci.edu
To: gcc-gnats@gcc.gnu.org
Subject: c/5277: NaN unexpectedly
Date: Fri, 04 Jan 2002 11:06:00 -0000	[thread overview]
Message-ID: <20020104190205.28407.qmail@sources.redhat.com> (raw)


>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:


             reply	other threads:[~2002-01-04 19:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-01-04 11:06 long [this message]
2002-01-06 10:36 Knox S. Long
2002-11-05  7:59 bangerth

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=20020104190205.28407.qmail@sources.redhat.com \
    --to=long@stsci.edu \
    --cc=gcc-gnats@gcc.gnu.org \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).