From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32206 invoked by alias); 27 Nov 2011 13:53:35 -0000 Received: (qmail 32197 invoked by uid 22791); 27 Nov 2011 13:53:34 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from sibelius.xs4all.nl (HELO glazunov.sibelius.xs4all.nl) (83.163.83.176) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 27 Nov 2011 13:53:17 +0000 Received: from glazunov.sibelius.xs4all.nl (kettenis@localhost [127.0.0.1]) by glazunov.sibelius.xs4all.nl (8.14.5/8.14.3) with ESMTP id pARDqlPb021483; Sun, 27 Nov 2011 14:52:47 +0100 (CET) Received: (from kettenis@localhost) by glazunov.sibelius.xs4all.nl (8.14.5/8.14.3/Submit) id pARDqjCg025404; Sun, 27 Nov 2011 14:52:45 +0100 (CET) Date: Sun, 27 Nov 2011 13:53:00 -0000 Message-Id: <201111271352.pARDqjCg025404@glazunov.sibelius.xs4all.nl> From: Mark Kettenis To: eliz@gnu.org CC: brobecker@adacore.com, andrew.smirnov@gmail.com, gdb-patches@sourceware.org In-reply-to: <83aa7k83p0.fsf@gnu.org> (message from Eli Zaretskii on Fri, 25 Nov 2011 20:19:55 +0200) Subject: Re: [PATCH 18/348] Fix -Wsahdow warnings References: <201111231640.pANGefc4031803@d06av02.portsmouth.uk.ibm.com> <201111231820.40486.pedro@codesourcery.com> <201111232023.pANKNcLf022983@glazunov.sibelius.xs4all.nl> <20111124220057.GU13809@adacore.com> <83hb1s8l5c.fsf@gnu.org> <201111251511.pAPFBBkP007292@glazunov.sibelius.xs4all.nl> <83ehww8b1t.fsf@gnu.org> <201111251626.pAPGQ3rN016558@glazunov.sibelius.xs4all.nl> <83aa7k83p0.fsf@gnu.org> 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: 2011-11/txt/msg00728.txt.bz2 > Date: Fri, 25 Nov 2011 20:19:55 +0200 > From: Eli Zaretskii > > > Date: Fri, 25 Nov 2011 17:26:04 +0100 (CET) > > From: Mark Kettenis > > CC: brobecker@adacore.com, andrew.smirnov@gmail.com, > > gdb-patches@sourceware.org > > > > Since there is absolutely no problem with a local variable that has > > the same name as a library function, this is bad. > > You are, in effect, saying that the wisdom of coding "down the middle > of a programming language" is wrong. We will have to disagree on > that, sorry. FWIW, I don't think a large project should live > dangerously just because some versions of some compiler will flag > these clashes even without -Wshadow. I think you're still missing my point. What I'm saying is that a local variable shadowing a function is never a problem. It would only be a problem if inside the function that has the local variable, you'd (accidentally) try to invoke the function. That's why I came up with the example: void foo(void); void bar(void) { int foo; foo(); } where the function foo() is being called when it is being shadowed by a local variable. This won't compile on *any* C compiler, simply because it isn't legal C.