Re: Using -Wshadow

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Neil Conway <neilc(at)samurai(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Using -Wshadow
Date: 2003-11-24 21:10:26
Message-ID: 22920.1069708226@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Peter Eisentraut <peter_e(at)gmx(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Neil Conway 2003-11-24 23:28:33 Re: logical column position
Previous Message Peter Eisentraut 2003-11-24 20:51:50 Re: Using -Wshadow