This is the mail archive of the
mailing list for the GDB project.
Re: [PATCH 18/348] Fix -Wsahdow warnings
>>>>> "Andrey" == Andrey Smirnov <firstname.lastname@example.org> writes:
Andrey> I know I probably should go to GCC mailing list and ask that question
Andrey> there, but anyways, would this patch cause gcc to stop generating the
Andrey> warning about local variable shadowing global one from system headers?
Yeah, that's what it does.
Andrey> I hope that kinds of shadowing would still be detectable even with this
Andrey> patch applied.
Why is that?
I do think the GCC patch could probably be better. That is, I think a
slightly different rule would be an improvement, something like
"generally do not warn about shadowing things declared in system
headers, except if a local function pointer variable shadows a system
function". That would eliminate the potential for some kinds of bugs.
Tom> Still, what it does is prevent the warning when shadowing something from
Tom> a system header. ÂThis seems decent to me and in particular will, I
Tom> think, largely address Mark's concerns.
Andrey> It would pretty much solve that problem, yes, but still it would
Andrey> divide patch submitters into two groups those who have newest gcc and
Andrey> -Wshadow enabled by default, and those who don't. And the people
Andrey> without -Wshadow enabled compilers would be, on occasion, breaking the
Andrey> build because they have no means to check for -Wshadow caused errors.
Andrey> I hope I missing something and it is not the case, but that how the
Andrey> things seems to me now.
Yes, I think it would result in some periodic breakage until the newer
GCC is widely distributed. I'm willing to put up with that. We already
put up with it, in a way, due to other GCC differences... see the
uninitialized variable patches or FORTIFY_SOURCE patches that go in from
time to time.
If the configury part is set up properly, then this warning will simply
auto-enable for people when they upgrade GCC. So, it isn't like we'll
just forget about it; more like at some point we'll all be joining in :)