Re: Using -Wshadow

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Neil Conway <neilc(at)samurai(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Using -Wshadow
Date: 2003-11-24 17:42:35
Message-ID: 21379.1069695755@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Neil Conway <neilc(at)samurai(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kurt Roeckx 2003-11-24 17:47:18 Re: Using -Wshadow
Previous Message Oleg Bartunov 2003-11-24 17:38:16 regexp incompatibilites 7.3 and 7.4