FYI: -Wunused warning in cp-namespace.c with old glibc...

Joel Brobecker brobecker@adacore.com
Wed Dec 30 10:48:00 GMT 2009


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: wunused.diff
Type: text/x-diff
Size: 1123 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20091230/9a62f9ef/attachment.bin>


More information about the Gdb-patches mailing list