Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Fix DOUBLEST build warnings
@ 2006-02-23 23:55 Randolph Chung
  2006-02-24  2:34 ` Randolph Chung
  0 siblings, 1 reply; 2+ messages in thread
From: Randolph Chung @ 2006-02-23 23:55 UTC (permalink / raw)
  To: gdb-patches

Building the latest gdb on hppa-linux, I found some warnings when 
DOUBLEST is double instead of long double (we have some long double 
issues on this platform at the moment, may also affect hppa-bsd)

The attached patch fixes these. Tested with no regressions on 
hppa-linux, and it now builds with -Werror. OK to apply?

One thing to note - DOUBLEST_FORMAT is only used in scanf format strings 
at the moment - for double args, the format string is different for 
scanf and printf, which may lead to some confusion.

randolph



2006-02-23  Randolph Chung  <tausq@debian.org>

	* doublest.h (DOUBLEST_FORMAT) [!HAVE_LONG_DOUBLE ||
	!SCANF_HAS_LONG_DOUBLE]: Correct format string.
	* ada-lex.l (processReal): Use DOUBLEST-dependent format string.
	* valprint.c (print_floating): Cast long double argument to
	match format string.

Index: doublest.h
===================================================================
RCS file: /cvs/src/src/gdb/doublest.h,v
retrieving revision 1.17
diff -u -p -r1.17 doublest.h
--- doublest.h	14 Feb 2006 19:05:40 -0000	1.17
+++ doublest.h	23 Feb 2006 15:30:38 -0000
@@ -53,7 +53,7 @@ typedef long double DOUBLEST;
  # define DOUBLEST_FORMAT "%Lg"
  #else
  typedef double DOUBLEST;
-# define DOUBLEST_FORMAT "%g"
+# define DOUBLEST_FORMAT "%lg"
  /* If we can't scan or print long double, we don't want to use it
     anywhere.  */
  # undef HAVE_LONG_DOUBLE
Index: ada-lex.l
===================================================================
RCS file: /cvs/src/src/gdb/ada-lex.l,v
retrieving revision 1.14
diff -u -p -r1.14 ada-lex.l
--- ada-lex.l	8 Jan 2006 07:19:40 -0000	1.14
+++ ada-lex.l	23 Feb 2006 15:30:38 -0000
@@ -444,7 +444,7 @@ processReal (const char *num0)
  {
  #if defined (PRINTF_HAS_LONG_DOUBLE)
    if (sizeof (DOUBLEST) > sizeof (double))
-    sscanf (num0, "%Lg", &yylval.typed_val_float.dval);
+    sscanf (num0, DOUBLEST_FORMAT, &yylval.typed_val_float.dval);
    else
  #endif
      {
Index: valprint.c
===================================================================
RCS file: /cvs/src/src/gdb/valprint.c,v
retrieving revision 1.59
diff -u -p -r1.59 valprint.c
--- valprint.c	18 Jan 2006 21:24:19 -0000	1.59
+++ valprint.c	23 Feb 2006 15:30:38 -0000
@@ -476,7 +476,7 @@ print_floating (const gdb_byte *valaddr,
        fprintf_filtered (stream, "%.17g", (double) doub);
    else
  #ifdef PRINTF_HAS_LONG_DOUBLE
-    fprintf_filtered (stream, "%.35Lg", doub);
+    fprintf_filtered (stream, "%.35Lg", (long double) doub);
  #else
      /* This at least wins with values that are representable as
         doubles.  */


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Fix DOUBLEST build warnings
  2006-02-23 23:55 Fix DOUBLEST build warnings Randolph Chung
@ 2006-02-24  2:34 ` Randolph Chung
  0 siblings, 0 replies; 2+ messages in thread
From: Randolph Chung @ 2006-02-24  2:34 UTC (permalink / raw)
  To: gdb-patches

Randolph Chung wrote:
> Building the latest gdb on hppa-linux, I found some warnings when 
> DOUBLEST is double instead of long double (we have some long double 
> issues on this platform at the moment, may also affect hppa-bsd)

I see that drow beat me to this, so nevermind :)

randolph


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-02-23 23:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-23 23:55 Fix DOUBLEST build warnings Randolph Chung
2006-02-24  2:34 ` Randolph Chung

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox