public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/96747] New: -Wshadow accepts included extern variable shadowing
@ 2020-08-22 16:49 matous-dev at criptext dot com
  2020-08-23 14:31 ` [Bug c/96747] " harald at gigawatt dot nl
  2020-08-23 22:12 ` matous-dev at criptext dot com
  0 siblings, 2 replies; 3+ messages in thread
From: matous-dev at criptext dot com @ 2020-08-22 16:49 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 96747
           Summary: -Wshadow accepts included extern variable shadowing
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: matous-dev at criptext dot com
  Target Milestone: ---

Created attachment 49098
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49098&action=edit
-save-temps *.i output

When I compile the attached code with 
gcc -Wshadow ./gcc-shadow-test.c
it passes with no output/warnings. The warning about shadowing is displayed
properly by g++, clang and clang++ and the first print() actually proves that
gcc does see the "environ" variable from unistd.h but ignores it when resolving
shadowing.

gcc -v:
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/10.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with:
/var/tmp/portage/sys-devel/gcc-10.2.0/work/gcc-10.2.0/configure
--host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr
--bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/10.2.0
--includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/include
--datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/10.2.0
--mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/10.2.0/man
--infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/10.2.0/info
--with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/include/g++-v10
--with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/10.2.0/python
--enable-languages=c,c++,fortran --enable-obsolete --enable-secureplt
--disable-werror --with-system-zlib --enable-nls --without-included-gettext
--enable-checking=release --with-bugurl=https://bugs.gentoo.org/
--with-pkgversion='Gentoo 10.2.0 p1' --disable-esp --enable-libstdcxx-time
--with-build-config=bootstrap-lto --enable-shared --enable-threads=posix
--enable-__cxa_atexit --enable-clocale=gnu --enable-multilib
--with-multilib-list=m32,m64 --disable-fixed-point --enable-targets=all
--enable-libgomp --disable-libssp --disable-libada --disable-systemtap
--enable-vtable-verify --with-zstd --enable-lto --without-isl
--enable-default-pie --enable-default-ssp
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.2.0 (Gentoo 10.2.0 p1)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c/96747] -Wshadow accepts included extern variable shadowing
  2020-08-22 16:49 [Bug c/96747] New: -Wshadow accepts included extern variable shadowing matous-dev at criptext dot com
@ 2020-08-23 14:31 ` harald at gigawatt dot nl
  2020-08-23 22:12 ` matous-dev at criptext dot com
  1 sibling, 0 replies; 3+ messages in thread
From: harald at gigawatt dot nl @ 2020-08-23 14:31 UTC (permalink / raw)
  To: gcc-bugs

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?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c/96747] -Wshadow accepts included extern variable shadowing
  2020-08-22 16:49 [Bug c/96747] New: -Wshadow accepts included extern variable shadowing matous-dev at criptext dot com
  2020-08-23 14:31 ` [Bug c/96747] " harald at gigawatt dot nl
@ 2020-08-23 22:12 ` matous-dev at criptext dot com
  1 sibling, 0 replies; 3+ messages in thread
From: matous-dev at criptext dot com @ 2020-08-23 22:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Martin Matous <matous-dev at criptext dot com> ---
Other compiler's behavior does makes more sense, but yeah, personal opinion. In
case the patch ends up not being reverted the docs at
https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wshadow should
probably be clarified about what kind of shadowing is silently ignored.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-08-23 22:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-22 16:49 [Bug c/96747] New: -Wshadow accepts included extern variable shadowing matous-dev at criptext dot com
2020-08-23 14:31 ` [Bug c/96747] " harald at gigawatt dot nl
2020-08-23 22:12 ` matous-dev at criptext dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).