This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Fix DOUBLEST build warnings
- From: Randolph Chung <randolph at tausq dot org>
- To: gdb-patches at sources dot redhat dot com
- Date: Fri, 24 Feb 2006 07:48:47 +0800
- Subject: Fix DOUBLEST build warnings
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. */