This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[ezolt@perf.zko.dec.com] libc/1882: atof("NaN") doesn't return quiet NaN and doesn't detect IEEE mode.



Alpha glibc developers and users,

can you please have a look at the appended bug report?

Thanks,
Andreas


Subject: Topics

Topics:
   libc/1882: atof("NaN") doesn't return quiet NaN and doesn't detect IEEE mode.




>Number:         1882
>Category:       libc
>Synopsis:       atof("NaN") doesn't return quiet NaN and doesn't detect IEEE mode.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    libc-gnats
>State:          open
>Class:          sw-bug
>Submitter-Id:   unknown
>Arrival-Date:   Fri Sep 01 09:20:02 EDT 2000
>Last-Modified:
>Originator:     ezolt@perf.zko.dec.com
>Organization:
net
>Release:        glibc-2.1.3-16
>Environment:
Red Hat Linux release 6.2 (Zoot) (Alpha/Linux)
--------------------------------
glibc-2.1.3-16

Compaq C V6.2-504 on Linux 2.2.14 alpha
Compiler Driver V6.2-504 (Linux) cc Driver
Installed as ccc-6.2.9.504-2
Red Hat Linux release 6.2 (Zoot)
Using /usr/lib/gcc-lib/alpha-redhat-linux/egcs-2.91.66.
>Description:
        I am seeing a problem in CPU2000 perl test workload on Alpha/Linux.  
More specifically, I am seeing a floating point exception.  This is very 
similar to the problem that another engineer had when transitioning from Tru64 
v4.0 to Tru64 5.0.

When compiling with -ieee (with both Gcc & ccc), perl works just fine.  Without
-ieee & -mieee, there is a floating point exception.  This appears to depend on
the value that atof (& strtod) returns when passed a "NaN". 

When the following "NaN"-testing program is run, Redhat Linux 6.2
seems to behave differently than both Tru64 4.0 & 5.0.  Redhat Linux
5.2, seems to behave like Tru64 4.0.  (Returns zero)

Test Results
------------

Red Hat Linux release 5.2 (Apollo)
----------------------------------
glibc-2.0.7-29

Compaq C X6.2-259 on Linux 2.2.3 alpha
Compiler Driver X6.2-259 (Linux) cc Driver
Red Hat Linux release 5.2 (Apollo)
Using /usr/lib/gcc-lib/alpha-redhat-linux/egcs-2.90.29.

Zero.l = 0x0000000000000000
NaNQ.l = 0xfff8000000000000
what.l = 0x0000000000000000
Looks like you are on a V4 system


Red Hat Linux release 6.2 (Zoot)
--------------------------------
glibc-2.1.3-16

Compaq C V6.2-504 on Linux 2.2.14 alpha
Compiler Driver V6.2-504 (Linux) cc Driver
Installed as ccc-6.2.9.504-2
Red Hat Linux release 6.2 (Zoot)
Using /usr/lib/gcc-lib/alpha-redhat-linux/egcs-2.91.66.

Zero.l = 0x0000000000000000
NaNQ.l = 0xfff8000000000000
what.l = 0x7ff8000000000000
Unknown result from atof

It appears that there are TWO bugs. 

1) GNU Libc's atof (and strtod) is not returning a quiet NaN.

The Alpha architecture defines a lot of different bit patterns to
be quiet NaNs.  0x7ff8000000000000 is a quiet NaN.  We would probably
prefer that atof("NaN") return the *canonical* quiet NaN
(0xfff8000000000000).  Alpha Linux libc should do this since the hardware 
produces the canonical quiet NaN when it needs a quiet NaN value and it 
would be valuable that atof("NaN") produce the same bit pattern as the hardware.

2) GNU libc's atof (and strtod) do not check the IEEE mode to determine what
"NaN", "Inf" and friends should return.  (0.0 is preferably for NaN in non-ieee
mode)

It would also be nice if the Alpha Linux libc figured out the
-mieee setting of its callers.  There is no standard requiring this
but we should suggest the behavior to the Alpha Linux libc maintainers.
This would allow us to compile code without the performance-penalty of "-mieee".
>How-To-Repeat:
nan-tester.c: 
/*
 * On Compaq Tru64 UNIX X5.1-7 (Rev. 446), atof("NaN") returns a quiet NaN.
 * Is this a new feature?  Is it standard?  On V4.0 systems, it returns 0.0.
 */

extern int printf(const char *, ...);
extern double atof(const char *);

typedef union {
  long l;
  double d;
} ld_t;

ld_t NaNQ = { 0xfff8000000000000L };
ld_t Zero = { 0x0000000000000000L };

int main(int argc, char ** argv)
{
  ld_t what;
  what.d = atof("NaN");
  printf("Zero.l = 0x%016lx\n", Zero.l);
  printf("NaNQ.l = 0x%016lx\n", NaNQ.l);
  printf("what.l = 0x%016lx\n", what.l);
  if (what.l == Zero.l)
    printf("Looks like you are on a V4 system\n");
  else if (what.l == NaNQ.l)
    printf("Looks like you are on a V5 system\n");
  else
    printf("Unknown result from atof\n");
  return 0;
}



%0
>Fix:
>Audit-Trail:
>Unformatted:





-- 
 Andreas Jaeger
  SuSE Labs aj@suse.de
   private aj@arthur.inka.de
    http://www.suse.de/~aj

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]