This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Function pointer parameters and -Wshadow
- From: Ian Lance Taylor <iant at google dot com>
- To: Ferenc KovÃcs <derefer at gmail dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Mon, 16 Mar 2009 12:06:01 -0700
- Subject: Re: Function pointer parameters and -Wshadow
- References: <200903151329.21384.derefer@gmail.com>
Ferenc KovÃcs <derefer@gmail.com> writes:
> When I compile a header with g++ trunk on x86_64 using -Wshadow containing
> function declarations like this:
>
> int g(int a, int (*b)(int a));
>
> /* Originally, I found it in openssl's bn.h BN_BLINDING_create_param() and I
> got a bunch of warnings from all .cc files including this header. */
>
> I get:
>
> shadow.h:2: warning: declaration of 'int a' shadows a parameter
> shadow.h:2: warning: shadowed declaration is here
>
> I don't see the reason for this warning, because the parameters of the second
> parameter `b' AFAIK have nothing to do with parameters of the original
> function `g'. (With gcc -Wshadow it compiles with no warnings.)
>
> It seems to me, that the warning is present from g++ 4.4 revision 140120,
> which was a fix for PR37302.
>
> Is it the expected behavior? I haven't checked the standard yet...
There is no standard for -Wshadow.
I agree that this particular instance of the -Wshadow warning is
useless. I encourage you to file a bug report about it.
Ian