bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: -0.0L on Irix


From: Eric Blake
Subject: Re: -0.0L on Irix
Date: Mon, 12 Jan 2009 06:55:17 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.19) Gecko/20081209 Thunderbird/2.0.0.19 Mnenhy/0.7.5.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Eric Blake on 1/9/2009 7:50 PM:
> But so far, I've discovered this
> about -0.0L on Irix 6.2:
> 
> With 'cc -n32', LDBL_MIN is a compile-time constant; but with 'gcc', I get
> an error when trying to use it to initialize a global variable (note,
> however, that it can be used inside the body of a method):
> 
> foo.c:9: error: initializer element is not constant
> 
> 
> My conclusions: cc is buggy when representing -0.0L as a global variable,
> but any variant that computes -0.0L during the body of a method works.

I tested on Irix 6.2, but suspect 6.5 will have similar behavior.  With
this patch, both cc and gcc pass all 33 tests created by this:

gnulib-tool --create-testdir --dir=testdir2 --with-tests ceill floorl
frexpl isnan isnanl ldexpl roundl signbit snprintf-posix sprintf-posix
truncl vasnprintf-posix vasprintf-posix

whereas without the patch, cc compiled all tests but failed many of them,
and gcc failed to even compile some of the tests.  I'm going ahead and
committing it.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAklrS8UACgkQ84KuGfSFAYBYbgCgzvUBFa99MoAzi4S7k+VOCE/B
bvEAoNVy3LSQYQ/M0Xd0GKUTbF2nC4sj
=/vlT
-----END PGP SIGNATURE-----
>From b7cb23a66cd14b33c65e4fc95cbc5e6a4ed51fee Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Mon, 12 Jan 2009 06:52:18 -0700
Subject: [PATCH] tests: IRIX 6.2 cc can't compile -0.0 into .data

* tests/test-ceill.c (minus_zero): Compute -0.0L at runtime,
rather than at compile-time.
* tests/test-floorl.c (minus_zero): Likewise.
* tests/test-frexpl.c (minus_zero): Likewise.
* tests/test-isnan.c (minus_zerol): Likewise.
* tests/test-isnanl.h (minus_zero): Likewise.
* tests/test-ldexpl.c (minus_zero): Likewise.
* tests/test-roundl.c (minus_zero): Likewise.
* tests/test-signbit.c (minus_zerol): Likewise.
* tests/test-snprintf-posix.h (minus_zerol): Likewise.
* tests/test-sprintf-posix.h (minus_zerol): Likewise.
* tests/test-truncl.c (minus_zero): Likewise.
* tests/test-vasnprintf-posix.c (minus_zerol): Likewise.
* tests/test-vasprintf-posix.c (minus_zerol): Likewise.
Reported by Tom G. Christensen and Nelson H. F. Beebe.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog                     |   19 +++++++++++++++++++
 tests/test-ceill.c            |   10 ++++++++--
 tests/test-floorl.c           |   10 ++++++++--
 tests/test-frexpl.c           |   10 ++++++++--
 tests/test-isnan.c            |   10 ++++++++--
 tests/test-isnanl.h           |   10 ++++++++--
 tests/test-ldexpl.c           |   10 ++++++++--
 tests/test-roundl.c           |   12 +++++++++---
 tests/test-signbit.c          |   10 ++++++++--
 tests/test-snprintf-posix.h   |   10 ++++++++--
 tests/test-sprintf-posix.h    |   10 ++++++++--
 tests/test-truncl.c           |   10 ++++++++--
 tests/test-vasnprintf-posix.c |   10 ++++++++--
 tests/test-vasprintf-posix.c  |   10 ++++++++--
 14 files changed, 124 insertions(+), 27 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0c9bcfb..de933c5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2009-01-12  Eric Blake  <address@hidden>
+
+       tests: IRIX 6.2 cc can't compile -0.0 into .data
+       * tests/test-ceill.c (minus_zero): Compute -0.0L at runtime,
+       rather than at compile-time.
+       * tests/test-floorl.c (minus_zero): Likewise.
+       * tests/test-frexpl.c (minus_zero): Likewise.
+       * tests/test-isnan.c (minus_zerol): Likewise.
+       * tests/test-isnanl.h (minus_zero): Likewise.
+       * tests/test-ldexpl.c (minus_zero): Likewise.
+       * tests/test-roundl.c (minus_zero): Likewise.
+       * tests/test-signbit.c (minus_zerol): Likewise.
+       * tests/test-snprintf-posix.h (minus_zerol): Likewise.
+       * tests/test-sprintf-posix.h (minus_zerol): Likewise.
+       * tests/test-truncl.c (minus_zero): Likewise.
+       * tests/test-vasnprintf-posix.c (minus_zerol): Likewise.
+       * tests/test-vasprintf-posix.c (minus_zerol): Likewise.
+       Reported by Tom G. Christensen and Nelson H. F. Beebe.
+
 2009-01-09  Paolo Bonzini  <address@hidden>
 
        regex: fix glibc bug 9697
diff --git a/tests/test-ceill.c b/tests/test-ceill.c
index 49e0c65..d1f0266 100644
--- a/tests/test-ceill.c
+++ b/tests/test-ceill.c
@@ -1,5 +1,5 @@
 /* Test of rounding towards positive infinity.
-   Copyright (C) 2007-2008 Free Software Foundation, Inc.
+   Copyright (C) 2007-2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -41,10 +41,16 @@
 
 /* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
    So we use minus_zero instead.
+   IRIX cc can't put -0.0L into .data, but can compute at runtime.
    Note that the expression -LDBL_MIN * LDBL_MIN does not work on other
    platforms, such as when cross-compiling to PowerPC on MacOS X 10.5.  */
 #if defined __hpux || defined __sgi
-long double minus_zero = -LDBL_MIN * LDBL_MIN;
+static long double
+compute_minus_zero (void)
+{
+  return -LDBL_MIN * LDBL_MIN;
+}
+# define minus_zero compute_minus_zero ()
 #else
 long double minus_zero = -0.0L;
 #endif
diff --git a/tests/test-floorl.c b/tests/test-floorl.c
index 9a8e5a8..14979e6 100644
--- a/tests/test-floorl.c
+++ b/tests/test-floorl.c
@@ -1,5 +1,5 @@
 /* Test of rounding towards negative infinity.
-   Copyright (C) 2007-2008 Free Software Foundation, Inc.
+   Copyright (C) 2007-2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -41,10 +41,16 @@
 
 /* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
    So we use minus_zero instead.
+   IRIX cc can't put -0.0L into .data, but can compute at runtime.
    Note that the expression -LDBL_MIN * LDBL_MIN does not work on other
    platforms, such as when cross-compiling to PowerPC on MacOS X 10.5.  */
 #if defined __hpux || defined __sgi
-long double minus_zero = -LDBL_MIN * LDBL_MIN;
+static long double
+compute_minus_zero (void)
+{
+  return -LDBL_MIN * LDBL_MIN;
+}
+# define minus_zero compute_minus_zero ()
 #else
 long double minus_zero = -0.0L;
 #endif
diff --git a/tests/test-frexpl.c b/tests/test-frexpl.c
index 91f2d67..2b968b8 100644
--- a/tests/test-frexpl.c
+++ b/tests/test-frexpl.c
@@ -1,5 +1,5 @@
 /* Test of splitting a 'long double' into fraction and mantissa.
-   Copyright (C) 2007-2008 Free Software Foundation, Inc.
+   Copyright (C) 2007-2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -59,10 +59,16 @@
 
 /* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
    So we use minus_zero instead.
+   IRIX cc can't put -0.0L into .data, but can compute at runtime.
    Note that the expression -LDBL_MIN * LDBL_MIN does not work on other
    platforms, such as when cross-compiling to PowerPC on MacOS X 10.5.  */
 #if defined __hpux || defined __sgi
-long double minus_zero = -LDBL_MIN * LDBL_MIN;
+static long double
+compute_minus_zero (void)
+{
+  return -LDBL_MIN * LDBL_MIN;
+}
+# define minus_zero compute_minus_zero ()
 #else
 long double minus_zero = -0.0L;
 #endif
diff --git a/tests/test-isnan.c b/tests/test-isnan.c
index b5fa112..6149017 100644
--- a/tests/test-isnan.c
+++ b/tests/test-isnan.c
@@ -1,5 +1,5 @@
 /* Test of isnand() substitute.
-   Copyright (C) 2007-2008 Free Software Foundation, Inc.
+   Copyright (C) 2007-2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -50,10 +50,16 @@ double zerod = 0.0;
 
 /* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
    So we use minus_zerol instead.
+   IRIX cc can't put -0.0L into .data, but can compute at runtime.
    Note that the expression -LDBL_MIN * LDBL_MIN does not work on other
    platforms, such as when cross-compiling to PowerPC on MacOS X 10.5.  */
 #if defined __hpux || defined __sgi
-long double minus_zerol = -LDBL_MIN * LDBL_MIN;
+static long double
+compute_minus_zerol (void)
+{
+  return -LDBL_MIN * LDBL_MIN;
+}
+# define minus_zerol compute_minus_zerol ()
 #else
 long double minus_zerol = -0.0L;
 #endif
diff --git a/tests/test-isnanl.h b/tests/test-isnanl.h
index 8567f39..37e2857 100644
--- a/tests/test-isnanl.h
+++ b/tests/test-isnanl.h
@@ -1,5 +1,5 @@
 /* Test of isnanl() substitute.
-   Copyright (C) 2007-2008 Free Software Foundation, Inc.
+   Copyright (C) 2007-2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -35,10 +35,16 @@
 
 /* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
    So we use minus_zero instead.
+   IRIX cc can't put -0.0L into .data, but can compute at runtime.
    Note that the expression -LDBL_MIN * LDBL_MIN does not work on other
    platforms, such as when cross-compiling to PowerPC on MacOS X 10.5.  */
 #if defined __hpux || defined __sgi
-long double minus_zero = -LDBL_MIN * LDBL_MIN;
+static long double
+compute_minus_zero (void)
+{
+  return -LDBL_MIN * LDBL_MIN;
+}
+# define minus_zero compute_minus_zero ()
 #else
 long double minus_zero = -0.0L;
 #endif
diff --git a/tests/test-ldexpl.c b/tests/test-ldexpl.c
index 272fc4f..395c00f 100644
--- a/tests/test-ldexpl.c
+++ b/tests/test-ldexpl.c
@@ -1,5 +1,5 @@
 /* Test of multiplying a 'long double' by a power of 2.
-   Copyright (C) 2007-2008 Free Software Foundation, Inc.
+   Copyright (C) 2007-2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -41,10 +41,16 @@
 
 /* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
    So we use minus_zero instead.
+   IRIX cc can't put -0.0L into .data, but can compute at runtime.
    Note that the expression -LDBL_MIN * LDBL_MIN does not work on other
    platforms, such as when cross-compiling to PowerPC on MacOS X 10.5.  */
 #if defined __hpux || defined __sgi
-long double minus_zero = -LDBL_MIN * LDBL_MIN;
+static long double
+compute_minus_zero (void)
+{
+  return -LDBL_MIN * LDBL_MIN;
+}
+# define minus_zero compute_minus_zero ()
 #else
 long double minus_zero = -0.0L;
 #endif
diff --git a/tests/test-roundl.c b/tests/test-roundl.c
index 1da3f44..51cd1cd 100644
--- a/tests/test-roundl.c
+++ b/tests/test-roundl.c
@@ -1,9 +1,9 @@
 /* Test of rounding to nearest, breaking ties away from zero.
-   Copyright (C) 2007-2008 Free Software Foundation, Inc.
+   Copyright (C) 2007-2009 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2, or (at your option)
+   the Free Software Foundation; either version 3, or (at your option)
    any later version.
 
    This program is distributed in the hope that it will be useful,
@@ -43,10 +43,16 @@
 
 /* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
    So we use minus_zero instead.
+   IRIX cc can't put -0.0L into .data, but can compute at runtime.
    Note that the expression -LDBL_MIN * LDBL_MIN does not work on other
    platforms, such as when cross-compiling to PowerPC on MacOS X 10.5.  */
 #if defined __hpux || defined __sgi
-long double minus_zero = -LDBL_MIN * LDBL_MIN;
+static long double
+compute_minus_zero (void)
+{
+  return -LDBL_MIN * LDBL_MIN;
+}
+# define minus_zero compute_minus_zero ()
 #else
 long double minus_zero = -0.0L;
 #endif
diff --git a/tests/test-signbit.c b/tests/test-signbit.c
index d6efe08..97f68e6 100644
--- a/tests/test-signbit.c
+++ b/tests/test-signbit.c
@@ -1,5 +1,5 @@
 /* Test of signbit() substitute.
-   Copyright (C) 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -49,10 +49,16 @@ long double zerol = 0.0L;
 
 /* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
    So we use minus_zerol instead.
+   IRIX cc can't put -0.0L into .data, but can compute at runtime.
    Note that the expression -LDBL_MIN * LDBL_MIN does not work on other
    platforms, such as when cross-compiling to PowerPC on MacOS X 10.5.  */
 #if defined __hpux || defined __sgi
-long double minus_zerol = -LDBL_MIN * LDBL_MIN;
+static long double
+compute_minus_zerol (void)
+{
+  return -LDBL_MIN * LDBL_MIN;
+}
+# define minus_zerol compute_minus_zerol ()
 #else
 long double minus_zerol = -0.0L;
 #endif
diff --git a/tests/test-snprintf-posix.h b/tests/test-snprintf-posix.h
index 09b1867..9fb2e67 100644
--- a/tests/test-snprintf-posix.h
+++ b/tests/test-snprintf-posix.h
@@ -1,5 +1,5 @@
 /* Test of POSIX compatible vsnprintf() and snprintf() functions.
-   Copyright (C) 2007-2008 Free Software Foundation, Inc.
+   Copyright (C) 2007-2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -33,10 +33,16 @@ double zerod = 0.0;
 
 /* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
    So we use minus_zerol instead.
+   IRIX cc can't put -0.0L into .data, but can compute at runtime.
    Note that the expression -LDBL_MIN * LDBL_MIN does not work on other
    platforms, such as when cross-compiling to PowerPC on MacOS X 10.5.  */
 #if defined __hpux || defined __sgi
-long double minus_zerol = -LDBL_MIN * LDBL_MIN;
+static long double
+compute_minus_zerol (void)
+{
+  return -LDBL_MIN * LDBL_MIN;
+}
+# define minus_zerol compute_minus_zerol ()
 #else
 long double minus_zerol = -0.0L;
 #endif
diff --git a/tests/test-sprintf-posix.h b/tests/test-sprintf-posix.h
index 5fb9250..e8b8ba8 100644
--- a/tests/test-sprintf-posix.h
+++ b/tests/test-sprintf-posix.h
@@ -1,5 +1,5 @@
 /* Test of POSIX compatible vsprintf() and sprintf() functions.
-   Copyright (C) 2007-2008 Free Software Foundation, Inc.
+   Copyright (C) 2007-2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -33,10 +33,16 @@ double zerod = 0.0;
 
 /* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
    So we use minus_zerol instead.
+   IRIX cc can't put -0.0L into .data, but can compute at runtime.
    Note that the expression -LDBL_MIN * LDBL_MIN does not work on other
    platforms, such as when cross-compiling to PowerPC on MacOS X 10.5.  */
 #if defined __hpux || defined __sgi
-long double minus_zerol = -LDBL_MIN * LDBL_MIN;
+static long double
+compute_minus_zerol (void)
+{
+  return -LDBL_MIN * LDBL_MIN;
+}
+# define minus_zerol compute_minus_zerol ()
 #else
 long double minus_zerol = -0.0L;
 #endif
diff --git a/tests/test-truncl.c b/tests/test-truncl.c
index 4b00e35..aad677d 100644
--- a/tests/test-truncl.c
+++ b/tests/test-truncl.c
@@ -1,5 +1,5 @@
 /* Test of rounding towards zero.
-   Copyright (C) 2007-2008 Free Software Foundation, Inc.
+   Copyright (C) 2007-2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -41,10 +41,16 @@
 
 /* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
    So we use minus_zero instead.
+   IRIX cc can't put -0.0L into .data, but can compute at runtime.
    Note that the expression -LDBL_MIN * LDBL_MIN does not work on other
    platforms, such as when cross-compiling to PowerPC on MacOS X 10.5.  */
 #if defined __hpux || defined __sgi
-long double minus_zero = -LDBL_MIN * LDBL_MIN;
+static long double
+compute_minus_zero (void)
+{
+  return -LDBL_MIN * LDBL_MIN;
+}
+# define minus_zero compute_minus_zero ()
 #else
 long double minus_zero = -0.0L;
 #endif
diff --git a/tests/test-vasnprintf-posix.c b/tests/test-vasnprintf-posix.c
index bf12548..07c173e 100644
--- a/tests/test-vasnprintf-posix.c
+++ b/tests/test-vasnprintf-posix.c
@@ -1,5 +1,5 @@
 /* Test of POSIX compatible vasnprintf() and asnprintf() functions.
-   Copyright (C) 2007-2008 Free Software Foundation, Inc.
+   Copyright (C) 2007-2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -58,10 +58,16 @@ double zerod = 0.0;
 
 /* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
    So we use minus_zerol instead.
+   IRIX cc can't put -0.0L into .data, but can compute at runtime.
    Note that the expression -LDBL_MIN * LDBL_MIN does not work on other
    platforms, such as when cross-compiling to PowerPC on MacOS X 10.5.  */
 #if defined __hpux || defined __sgi
-long double minus_zerol = -LDBL_MIN * LDBL_MIN;
+static long double
+compute_minus_zerol (void)
+{
+  return -LDBL_MIN * LDBL_MIN;
+}
+# define minus_zerol compute_minus_zerol ()
 #else
 long double minus_zerol = -0.0L;
 #endif
diff --git a/tests/test-vasprintf-posix.c b/tests/test-vasprintf-posix.c
index 2f287fc..5f471b4 100644
--- a/tests/test-vasprintf-posix.c
+++ b/tests/test-vasprintf-posix.c
@@ -1,5 +1,5 @@
 /* Test of POSIX compatible vasprintf() and asprintf() functions.
-   Copyright (C) 2007-2008 Free Software Foundation, Inc.
+   Copyright (C) 2007-2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -57,10 +57,16 @@ double zerod = 0.0;
 
 /* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
    So we use minus_zerol instead.
+   IRIX cc can't put -0.0L into .data, but can compute at runtime.
    Note that the expression -LDBL_MIN * LDBL_MIN does not work on other
    platforms, such as when cross-compiling to PowerPC on MacOS X 10.5.  */
 #if defined __hpux || defined __sgi
-long double minus_zerol = -LDBL_MIN * LDBL_MIN;
+static long double
+compute_minus_zerol (void)
+{
+  return -LDBL_MIN * LDBL_MIN;
+}
+# define minus_zerol compute_minus_zerol ()
 #else
 long double minus_zerol = -0.0L;
 #endif
-- 
1.6.0.4


reply via email to

[Prev in Thread] Current Thread [Next in Thread]