[Bug c/96747] -Wshadow accepts included extern variable shadowing

harald at gigawatt dot nl gcc-bugzilla@gcc.gnu.org
Sun Aug 23 14:31:26 GMT 2020


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96747

Harald van Dijk <harald at gigawatt dot nl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |harald at gigawatt dot nl

--- Comment #1 from Harald van Dijk <harald at gigawatt dot nl> ---
This happens because environ is declared in a system header. The C frontend
warns when both declarations are not in a system header. The C++ frontend warns
when the second declaration is not in a system header.

Intuitively, the C++ frontend's behaviour makes more sense to me, but that is
just my personal opinion.

The C frontend's behaviour was changed intentionally, see
<https://gcc.gnu.org/legacy-ml/gcc-patches/2011-08/msg02017.html>, but -Wshadow
has since been enhanced so that it no longer warns about object declarations
shadowing functions. If that later enhancement already covers all of the cases
that that initial system headers patch was meant to suppress warnings for,
perhaps the initial patch can be reverted now?


More information about the Gcc-bugs mailing list