Function pointer parameters and -Wshadow

Ian Lance Taylor iant@google.com
Mon Mar 16 19:06:00 GMT 2009


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



More information about the Gcc-help mailing list