bug-gnulib
[Top][All Lists]
Advanced

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

Re: minus_zero-related tests fail to compile on ppc with recent gcc


From: Bruno Haible
Subject: Re: minus_zero-related tests fail to compile on ppc with recent gcc
Date: Sat, 18 Oct 2008 03:15:09 +0200
User-agent: KMail/1.5.4

Jim Meyering wrote:
> Markus Armbruster <address@hidden> wrote:
> > With the appended patch, koji ate it up:
> > http://koji.fedoraproject.org/koji/taskinfo?taskID=886652
> 
> Great!  Thanks a lot, Markus.
> 
> Bruno, FYI, Markus discovered that
> an upcoming idutils release fails to compile on ppc-based systems:
> (details here http://koji.fedoraproject.org/koji/taskinfo?taskID=886563)

Thanks for the report. Your build pages indicate a cross-compiling build,
and in this setting I can actually reproduce it. (While Nelson Beebe's
report says "Apple Mac OS X 10.x PowerPC", I could not reproduce any
problem on MacOS X 10.3.9.)

$ uname -sr
Darwin 9.3.0
$ gcc --version| head -1
i686-apple-darwin9-gcc-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5465)
$ cat foo.c
static long double one = 1.0L * 1.0L;
static long double quarter = 0.5L * 0.5L;
static long double third = 1.0L / 3.0L;
#include <float.h>
long double minus_zero = -LDBL_MIN * LDBL_MIN;
$ gcc -arch ppc -c foo.c
foo.c:3: error: initializer element is not constant
foo.c:5: error: initializer element is not constant

I don't much like the requirement to define minus_zero in every function
that needs it. Therefore I'm applying this. It also fixes the problem,
and takes care of the special compiler bugs in HP-UX cc and in IRIX 6.2 cc
(see <http://lists.gnu.org/archive/html/bug-gnulib/2008-10/msg00116.html>).


2008-10-17  Bruno Haible  <address@hidden>

        * m4/signbit.m4 (gl_SIGNBIT_TEST_PROGRAM): On platforms other than
        HP-UX and IRIX, use -0.0L.
        * tests/test-ceill.c (minus_zero): Likewise.
        * 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 Markus Armbruster <address@hidden> via Jim Meyering
        and by Nelson H. F. Beebe <address@hidden> via Eric Blake.

*** m4/signbit.m4.orig  2008-10-18 03:08:24.000000000 +0200
--- m4/signbit.m4       2008-10-18 03:02:23.000000000 +0200
***************
*** 131,139 ****
  double p0d = 0.0;
  double m0d = -p0d;
  /* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
!    So we use another constant expression instead.  */
  long double p0l = 0.0L;
! #ifdef __hpux
  long double m0l = -LDBL_MIN * LDBL_MIN;
  #else
  long double m0l = -p0l;
--- 131,141 ----
  double p0d = 0.0;
  double m0d = -p0d;
  /* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
!    So we use another constant expression instead.
!    But that expression does not work on other platforms, such as when
!    cross-compiling to PowerPC on MacOS X 10.5.  */
  long double p0l = 0.0L;
! #if defined __hpux || defined __sgi
  long double m0l = -LDBL_MIN * LDBL_MIN;
  #else
  long double m0l = -p0l;
*** tests/test-ceill.c.orig     2008-10-18 03:08:25.000000000 +0200
--- tests/test-ceill.c  2008-10-18 03:02:29.000000000 +0200
***************
*** 40,47 ****
    while (0)
  
  /* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
!    So we use minus_zero instead.  */
  long double minus_zero = -LDBL_MIN * LDBL_MIN;
  
  int
  main ()
--- 40,53 ----
    while (0)
  
  /* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
!    So we use minus_zero instead.
!    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;
+ #else
+ long double minus_zero = -0.0L;
+ #endif
  
  int
  main ()
*** tests/test-floorl.c.orig    2008-10-18 03:08:25.000000000 +0200
--- tests/test-floorl.c 2008-10-18 03:02:31.000000000 +0200
***************
*** 40,47 ****
    while (0)
  
  /* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
!    So we use minus_zero instead.  */
  long double minus_zero = -LDBL_MIN * LDBL_MIN;
  
  int
  main ()
--- 40,53 ----
    while (0)
  
  /* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
!    So we use minus_zero instead.
!    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;
+ #else
+ long double minus_zero = -0.0L;
+ #endif
  
  int
  main ()
*** tests/test-frexpl.c.orig    2008-10-18 03:08:25.000000000 +0200
--- tests/test-frexpl.c 2008-10-18 03:02:38.000000000 +0200
***************
*** 58,65 ****
  #endif
  
  /* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
!    So we use minus_zero instead.  */
  long double minus_zero = -LDBL_MIN * LDBL_MIN;
  
  static long double
  my_ldexp (long double x, int d)
--- 58,71 ----
  #endif
  
  /* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
!    So we use minus_zero instead.
!    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;
+ #else
+ long double minus_zero = -0.0L;
+ #endif
  
  static long double
  my_ldexp (long double x, int d)
*** tests/test-isnan.c.orig     2008-10-18 03:08:25.000000000 +0200
--- tests/test-isnan.c  2008-10-18 03:02:40.000000000 +0200
***************
*** 49,56 ****
  double zerod = 0.0;
  
  /* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
!    So we use minus_zerol instead.  */
  long double minus_zerol = -LDBL_MIN * LDBL_MIN;
  
  static void
  test_float (void)
--- 49,62 ----
  double zerod = 0.0;
  
  /* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
!    So we use minus_zerol instead.
!    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;
+ #else
+ long double minus_zerol = -0.0L;
+ #endif
  
  static void
  test_float (void)
*** tests/test-isnanl.h.orig    2008-10-18 03:08:25.000000000 +0200
--- tests/test-isnanl.h 2008-10-18 03:02:42.000000000 +0200
***************
*** 34,41 ****
    while (0)
  
  /* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
!    So we use minus_zero instead.  */
  long double minus_zero = -LDBL_MIN * LDBL_MIN;
  
  int
  main ()
--- 34,47 ----
    while (0)
  
  /* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
!    So we use minus_zero instead.
!    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;
+ #else
+ long double minus_zero = -0.0L;
+ #endif
  
  int
  main ()
*** tests/test-ldexpl.c.orig    2008-10-18 03:08:25.000000000 +0200
--- tests/test-ldexpl.c 2008-10-18 03:02:44.000000000 +0200
***************
*** 40,47 ****
    while (0)
  
  /* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
!    So we use minus_zero instead.  */
  long double minus_zero = -LDBL_MIN * LDBL_MIN;
  
  int
  main ()
--- 40,53 ----
    while (0)
  
  /* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
!    So we use minus_zero instead.
!    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;
+ #else
+ long double minus_zero = -0.0L;
+ #endif
  
  int
  main ()
*** tests/test-roundl.c.orig    2008-10-18 03:08:25.000000000 +0200
--- tests/test-roundl.c 2008-10-18 03:02:33.000000000 +0200
***************
*** 42,49 ****
    while (0)
  
  /* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
!    So we use minus_zero instead.  */
  long double minus_zero = -LDBL_MIN * LDBL_MIN;
  
  int
  main ()
--- 42,55 ----
    while (0)
  
  /* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
!    So we use minus_zero instead.
!    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;
+ #else
+ long double minus_zero = -0.0L;
+ #endif
  
  int
  main ()
*** tests/test-signbit.c.orig   2008-10-18 03:08:25.000000000 +0200
--- tests/test-signbit.c        2008-10-18 03:02:26.000000000 +0200
***************
*** 48,55 ****
     So we use -zerod instead.  */
  
  /* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
!    So we use minus_zerol instead.  */
  long double minus_zerol = -LDBL_MIN * LDBL_MIN;
  
  static void
  test_signbitf ()
--- 48,61 ----
     So we use -zerod instead.  */
  
  /* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
!    So we use minus_zerol instead.
!    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;
+ #else
+ long double minus_zerol = -0.0L;
+ #endif
  
  static void
  test_signbitf ()
*** tests/test-snprintf-posix.h.orig    2008-10-18 03:08:25.000000000 +0200
--- tests/test-snprintf-posix.h 2008-10-18 03:02:47.000000000 +0200
***************
*** 32,39 ****
  double zerod = 0.0;
  
  /* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
!    So we use minus_zerol instead.  */
  long double minus_zerol = -LDBL_MIN * LDBL_MIN;
  
  /* Representation of an 80-bit 'long double' as an initializer for a sequence
     of 'unsigned int' words.  */
--- 32,45 ----
  double zerod = 0.0;
  
  /* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
!    So we use minus_zerol instead.
!    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;
+ #else
+ long double minus_zerol = -0.0L;
+ #endif
  
  /* Representation of an 80-bit 'long double' as an initializer for a sequence
     of 'unsigned int' words.  */
*** tests/test-sprintf-posix.h.orig     2008-10-18 03:08:25.000000000 +0200
--- tests/test-sprintf-posix.h  2008-10-18 03:02:49.000000000 +0200
***************
*** 32,39 ****
  double zerod = 0.0;
  
  /* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
!    So we use minus_zerol instead.  */
  long double minus_zerol = -LDBL_MIN * LDBL_MIN;
  
  /* Representation of an 80-bit 'long double' as an initializer for a sequence
     of 'unsigned int' words.  */
--- 32,45 ----
  double zerod = 0.0;
  
  /* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
!    So we use minus_zerol instead.
!    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;
+ #else
+ long double minus_zerol = -0.0L;
+ #endif
  
  /* Representation of an 80-bit 'long double' as an initializer for a sequence
     of 'unsigned int' words.  */
*** tests/test-truncl.c.orig    2008-10-18 03:08:25.000000000 +0200
--- tests/test-truncl.c 2008-10-18 03:02:36.000000000 +0200
***************
*** 40,47 ****
    while (0)
  
  /* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
!    So we use minus_zero instead.  */
  long double minus_zero = -LDBL_MIN * LDBL_MIN;
  
  int
  main ()
--- 40,53 ----
    while (0)
  
  /* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
!    So we use minus_zero instead.
!    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;
+ #else
+ long double minus_zero = -0.0L;
+ #endif
  
  int
  main ()
*** tests/test-vasnprintf-posix.c.orig  2008-10-18 03:08:25.000000000 +0200
--- tests/test-vasnprintf-posix.c       2008-10-18 03:02:51.000000000 +0200
***************
*** 57,64 ****
  double zerod = 0.0;
  
  /* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
!    So we use minus_zerol instead.  */
  long double minus_zerol = -LDBL_MIN * LDBL_MIN;
  
  /* Representation of an 80-bit 'long double' as an initializer for a sequence
     of 'unsigned int' words.  */
--- 57,70 ----
  double zerod = 0.0;
  
  /* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
!    So we use minus_zerol instead.
!    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;
+ #else
+ long double minus_zerol = -0.0L;
+ #endif
  
  /* Representation of an 80-bit 'long double' as an initializer for a sequence
     of 'unsigned int' words.  */
*** tests/test-vasprintf-posix.c.orig   2008-10-18 03:08:25.000000000 +0200
--- tests/test-vasprintf-posix.c        2008-10-18 03:02:53.000000000 +0200
***************
*** 57,64 ****
  double zerod = 0.0;
  
  /* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
!    So we use minus_zerol instead.  */
  long double minus_zerol = -LDBL_MIN * LDBL_MIN;
  
  /* Representation of an 80-bit 'long double' as an initializer for a sequence
     of 'unsigned int' words.  */
--- 57,70 ----
  double zerod = 0.0;
  
  /* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
!    So we use minus_zerol instead.
!    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;
+ #else
+ long double minus_zerol = -0.0L;
+ #endif
  
  /* Representation of an 80-bit 'long double' as an initializer for a sequence
     of 'unsigned int' words.  */





reply via email to

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