Re: Using -Wshadow - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Using -Wshadow
Date
Msg-id 21379.1069695755@sss.pgh.pa.us
Whole thread Raw
In response to Using -Wshadow  (Neil Conway <neilc@samurai.com>)
Responses Re: Using -Wshadow
Re: Using -Wshadow
List pgsql-hackers
Neil Conway <neilc@samurai.com> 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 this for the PostgreSQL tree produces a lot of
> warnings. Would anyone object if I corrected these usages of a
> shadowed local variable, and then enabled this warning flag for
> standard GCC builds?

How many is "a lot"?  What are the odds that this would produce spurious
warnings on some platforms due to shadowing of platform-specific
functions or globals?

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.


> If there are any other GCC warning flags anyone else feels would be
> useful, let me know.

I have for a long time wanted to enable -Wcast-align and -Wpointer-arith,
but so far the tedium of getting rid of the warnings exceeds my
enthusiasm for it.

Another nice thing would be to get rid of the warnings about casting
between "char" and "unsigned char" that pop up on many (most?) non-gcc
compilers.  Most of the occurrences are in or near the multibyte stuff,
so maybe this could be coordinated somehow with Peter's plans for
upgrading locale support.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Oleg Bartunov
Date:
Subject: regexp incompatibilites 7.3 and 7.4
Next
From: Kurt Roeckx
Date:
Subject: Re: Using -Wshadow