About adding -Wshadow option by default (was Re: [PATCH 18/348] Fix -Wsahdow warnings)

Pierre Muller
2011-11-25T15:52:59Z

> -----Message d'origine-----
> De : gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> owner@sourceware.org] De la part de Joel Brobecker
> Envoyé : vendredi 25 novembre 2011 15:26
> À : Andrey Smirnov
> Cc : gdb-patches
> Objet : Re: [PATCH 18/348] Fix -Wsahdow warnings
>
> > Thanks for bringing that up, that is, IMHO, an excellent example.
> > The `block_found' in function conflicts with global variable declared
> > in symtab.c and it is not that just their names match, types are very
> > similar too one is `struct block **' another is `const struct *block'.
>
> Hmmm, I don't know how I missed that, as I grep'ed the source code.
> Or so I thought. Maybe a typo.
>
> In this particular case, yes, I agree, we should do something. We might
> prefer to rename the global variable, though; I think that a global
> variable with that name is bizarre.
>
> As to the final decision of enabling -Wshadow by default, I agree
> a little more to the idea, although not quite convinced yet. So far,
> Eli is pro. Mark is against. I'm 50/50. Unless we get more feedback
> from other GMs, you've done the work, we could at least try it and
> see where that gets us.

As you might have noticed from my last errorneous email,
-Wshadow is already used by default for Binutils
and the cases where it leads to problems are not that common
(even though my email was just about one of those cases
where a system specific function shadows a local variable...)

Anyhow, as it seems to indeed avoid some overlap that could lead
to hard to debug errors, I would also be in favor of enabling this,
even though my vote shouldn't really have any weight here...

Pierre Muller