Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Randolph Chung <randolph@tausq.org>
To: gdb-patches@sources.redhat.com
Subject: Fix DOUBLEST build warnings
Date: Thu, 23 Feb 2006 23:55:00 -0000	[thread overview]
Message-ID: <43FE49DF.8010101@tausq.org> (raw)

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.  */


             reply	other threads:[~2006-02-23 23:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-23 23:55 Randolph Chung [this message]
2006-02-24  2:34 ` Randolph Chung

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=43FE49DF.8010101@tausq.org \
    --to=randolph@tausq.org \
    --cc=gdb-patches@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox