Re: Using -Wshadow - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Using -Wshadow
Date
Msg-id 22920.1069708226@sss.pgh.pa.us
Whole thread Raw
In response to Re: Using -Wshadow  (Peter Eisentraut <peter_e@gmx.net>)
List pgsql-hackers
Peter Eisentraut <peter_e@gmx.net> writes:
> I'm not sure what the point is anyway.  Shadowing is perfectly
> well-defined and I've never heard of a real problem because of it.

Well, shadowing a formal parameter with a local variable is most likely
a mistake, and shadowing a local with a more-tightly-nested local is,
if not an outright mistake, certain to confuse future maintainers.
So I'd be in favor of getting rid of cases like that.

I can't get excited about forbidding shadowing of globals by locals,
though ... seems like that's practically giving up one of the
advantages of having a block-structured language in the first place.

BTW, what I find by experiment with gcc 2.95.3 is that
local-shadowing-formal is warned of just with -Wall, if the local is
declared at the function's outermost brace level, whether or not you
say -Wshadow.  So we already know we have none of those.
        regards, tom lane


pgsql-hackers by date:

Previous
From: david@fetter.org (David Fetter)
Date:
Subject: Re: Updates for RPMS.
Next
From: Neil Conway
Date:
Subject: Re: logical column position