This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] PR bootstrap/16787: Defining NAN in libiberty


The following patch should resolve PR bootstrap/16787 which is a
bootstrap failure building libiberty on Tru64 when using the HP/Compaq
C compiler as the host stage1 compiler.  The problem is that this
compiler doesn't like the compile-time expression "(0.0 / 0.0)".

The solution proposed below is to include the standard header <float.h>
which on Tru64 also conveniently defines DBL_QNAN, FLT_QNAN, DBL_SNAN,
FLT_SNAN.  We can safely use <float.h> when autoconf has detected its
presence with STDC_HEADERS, then if DBL_QNAN is defined, we can use
it to define NAN.  This test avoids earlier issues with bootstrap,
where during stage2 and stage3 GCC will use its own <float.h>, but
when using gcc there's no problem using 0.0/0.0 to generate a NaN.

A very similar patch was posted to "gcc" exactly a year ago today:
http://gcc.gnu.org/ml/gcc/2005-02/msg00173.html


OK for active branches once this patch is confirmed to fix this
long-time bootstrap problem?  This fix is complementary/compatible
with the alternate proposed approach of passing target-specific flags
to the native system compiler.  Unfortunately, efforts on that
resolution haven't progressed in the last 12 months, and this source
level fix simplifies the last of reusing libiberty in different
projects, and bootstrapping GCC without reading the INSTALL docs.



2006-02-07  Roger Sayle  <roger@eyesopen.com>
	    R. Scott Bailey  <scott.bailey@eds.com>
	    Bill Northcott  <w.northcott@unsw.edu.au>

	PR bootstrap/16787
	* floatformat.c: Include <float.h> where available.
	(NAN): Use value of DBL_QNAN if defined, and NAN isn't.


Index: floatformat.c
===================================================================
*** floatformat.c	(revision 110738)
--- floatformat.c	(working copy)
***************
*** 1,5 ****
  /* IEEE floating point support routines, for GDB, the GNU Debugger.
!    Copyright 1991, 1994, 1999, 2000, 2003, 2005
     Free Software Foundation, Inc.

  This file is part of GDB.
--- 1,5 ----
  /* IEEE floating point support routines, for GDB, the GNU Debugger.
!    Copyright 1991, 1994, 1999, 2000, 2003, 2005, 2006
     Free Software Foundation, Inc.

  This file is part of GDB.
*************** Foundation, Inc., 51 Franklin Street - F
*** 31,36 ****
--- 31,41 ----
  #include <string.h>
  #endif

+ /* On some platforms, <float.h> provides DBL_QNAN.  */
+ #ifdef STDC_HEADERS
+ #include <float.h>
+ #endif
+
  #include "ansidecl.h"
  #include "libiberty.h"
  #include "floatformat.h"
*************** Foundation, Inc., 51 Franklin Street - F
*** 44,51 ****
--- 49,60 ----
  #endif

  #ifndef NAN
+ #ifdef DBL_QNAN
+ #define NAN DBL_QNAN
+ #else
  #define NAN (0.0 / 0.0)
  #endif
+ #endif

  static unsigned long get_field (const unsigned char *,
                                  enum floatformat_byteorders,


Roger
--


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