From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16450 invoked by alias); 30 Dec 2009 10:48:55 -0000 Received: (qmail 16440 invoked by uid 22791); 30 Dec 2009 10:48:54 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 30 Dec 2009 10:48:48 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id DCA6C2BAAFC for ; Wed, 30 Dec 2009 05:48:46 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 8YV6K6ntm+Gz for ; Wed, 30 Dec 2009 05:48:46 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 512752BAABC for ; Wed, 30 Dec 2009 05:48:46 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id 7B8CEF5937; Wed, 30 Dec 2009 11:48:16 +0100 (CET) Date: Wed, 30 Dec 2009 10:48:00 -0000 From: Joel Brobecker To: gdb-patches@sourceware.org Subject: FYI: -Wunused warning in cp-namespace.c with old glibc... Message-ID: <20091230104816.GC548@adacore.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="l76fUT7nc3MelDdI" Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2009-12/txt/msg00435.txt.bz2 --l76fUT7nc3MelDdI Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 1855 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 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 --l76fUT7nc3MelDdI Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="wunused.diff" Content-length: 1123 commit cdf20aaf0a8b39a1f1ee427570a717f1c44ba272 Author: brobecke 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); --l76fUT7nc3MelDdI--