From: Joel Brobecker <brobecker@adacore.com>
To: gdb-patches@sourceware.org
Subject: FYI: -Wunused warning in cp-namespace.c with old glibc...
Date: Wed, 30 Dec 2009 10:48:00 -0000 [thread overview]
Message-ID: <20091230104816.GC548@adacore.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1855 bytes --]
Hello,
We're still supporting some pretty old x86-linux distributions at
AdaCore, and one of them comes with a now antiquated version of
the glic. And unfortunately, this version of glic plays some tricks
with strncpy, while these tricks are disabled on older glibcs
for GCC 3.2+:
/* Copy no more than N characters of SRC to DEST. */
#ifndef _HAVE_STRING_ARCH_strncpy
# if __GNUC_PREREQ (3, 2)
# define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)
# else
# define strncpy(dest, src, n) \
(__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n) \
? (strlen (src) + 1 >= ((size_t) (n)) \
? (char *) memcpy (dest, src, n) \
: strncpy (dest, src, n)) \
: strncpy (dest, src, n)))
# endif
#endif
On the older system, we end up getting a warning-turned-error:
[...]/gdb/cp-namespace.c: In function 'cp_lookup_transparent_type_loop':
[...]/gdb/cp-namespace.c:542: error: value computed is not used
The fix we applied locally, is to cast the function return to void.
I don't think that this part would be of interest for the FSF tree
(it's not exactly great to add an apparently useless cast), so I propose
we don't apply it, but I thought I'd still post it, in case someone else
might need it (or others think it should go in). For now, I'll assume
we don't want it.
2009-12-30 Joel Brobecker <brobecker@adacore.com>
Work around a -Wunused warning when glibc is too old.
* cp-namespace.c (cp_lookup_transparent_type_loop): Add cast to
void in function return to avoid a compiler warning.
"tested" by rebuilding GDB. I'll also get the nightly build results
tomorrow, but I didn't want to spend too much effort on this one.
--
Joel
[-- Attachment #2: wunused.diff --]
[-- Type: text/x-diff, Size: 1123 bytes --]
commit cdf20aaf0a8b39a1f1ee427570a717f1c44ba272
Author: brobecke <brobecke@f8352e7e-cb20-0410-8ce7-b5d9e71c585c>
Date: Wed Dec 30 10:28:08 2009 +0000
Work around a -Wunused warning when glibc is too old.
* cp-namespace.c (cp_lookup_transparent_type_loop): Add cast to
void in function return to avoid a compiler warning.
diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c
index a7a387b..35bb36c 100644
--- a/gdb/cp-namespace.c
+++ b/gdb/cp-namespace.c
@@ -539,7 +539,10 @@ cp_lookup_transparent_type_loop (const char *name, const char *scope,
full_name = alloca (scope_length + 2 + strlen (name) + 1);
strncpy (full_name, scope, scope_length);
- strncpy (full_name + scope_length, "::", 2);
+ /* Cast to void the return value of the following strncpy to avoid
+ a -Wunused warning from GCC when the glibc is too old (observed
+ with a 2.3.2 libc, while everything was fine with a 2.4 glibc). */
+ (void) strncpy (full_name + scope_length, "::", 2);
strcpy (full_name + scope_length + 2, name);
return basic_lookup_transparent_type (full_name);
next reply other threads:[~2009-12-30 10:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-30 10:48 Joel Brobecker [this message]
2009-12-30 13:22 ` Daniel Jacobowitz
2010-03-24 23:26 ` Joseph S. Myers
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=20091230104816.GC548@adacore.com \
--to=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
/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