[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: strtod bugs
From: |
Bruno Haible |
Subject: |
Re: strtod bugs |
Date: |
Wed, 2 Apr 2008 03:30:03 +0200 |
User-agent: |
KMail/1.5.4 |
Eric Blake wrote:
> * tests/test-math.c (main): Test it.
This test fails on IRIX 6.5 with CC="cc -O". The reason is that it inlines
the 'd == d' test. Here is the machine code that the compiler generates:
.ent main
.globl main
main: # 0x0
.frame $sp, 0, $31
.BB1.main: # 0x0
jr $31 # [0]
addiu $2,$0,1 # [1]
.end main
I'm committing this fix:
2008-04-01 Bruno Haible <address@hidden>
Fix test to work on IRIX 6.5 with cc.
* tests/test-math.c (numeric_equal): New function.
(main): Use it.
*** tests/test-math.c.orig 2008-04-02 03:29:08.000000000 +0200
--- tests/test-math.c 2008-04-02 03:27:36.000000000 +0200
***************
*** 30,38 ****
static float n = NAN;
#endif
int
main ()
{
double d = NAN;
! return d == d;
}
--- 30,49 ----
static float n = NAN;
#endif
+ /* Compare two numbers with ==.
+ This is a separate function because IRIX 6.5 "cc -O" miscompiles an
+ 'x == x' test. */
+ static int
+ numeric_equal (double x, double y)
+ {
+ return x == y;
+ }
+
int
main ()
{
double d = NAN;
! if (numeric_equal (d, d))
! return 1;
! return 0;
}