Neil Conway [EMAIL PROTECTED] writes:
GCC supports the -Wshadow command-line option:
-Wshadow
Warn whenever a local variable shadows another local
variable, parameter or global variable or whenever a
built-in function is shadowed.
Currently, enabling
On Mon, Nov 24, 2003 at 12:25:32PM -0500, Neil Conway wrote:
If there are any other GCC warning flags anyone else feels would be
useful, let me know.
I find the following also useful:
-Wcast-align
-Wcast-qual
-Wpointer-arith
-Wstrict-prototypes
And maybe:
-Waggregate-return
Kurt
Tom Lane [EMAIL PROTECTED] writes:
Neil Conway [EMAIL PROTECTED] writes:
Currently, enabling this for the PostgreSQL tree produces a lot of
warnings.
How many is a lot?
Maybe a couple hundred or so, but most of the warnings are derived
from a few globals with common names -- I would guess it
Tom Lane [EMAIL PROTECTED] writes:
I wouldn't object to something that catches shadowings of parameters
or local variables, but I think the flag as defined is not very
useful.
On closer examination, that seems like a prescient comment. There are
about 1100 distinct warnings enabled by this
Neil Conway writes:
The problem with #2 is the large number of warnings induced by system
headers: other platforms / standard libraries may well cause
additional instances of shadowing, so it might take a little while to
track down all the spurious warnings.
Yes, that's what I'm afraid of.
Peter Eisentraut [EMAIL PROTECTED] 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