public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/56100] New: spurious -Wshadow warning with local variable in template class
@ 2013-01-24 21:11 f.heckenbach@fh-soft.de
  2013-01-24 21:15 ` [Bug c++/56100] " pinskia at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: f.heckenbach@fh-soft.de @ 2013-01-24 21:11 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56100

             Bug #: 56100
           Summary: spurious -Wshadow warning with local variable in
                    template class
    Classification: Unclassified
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: f.heckenbach@fh-soft.de


Created attachment 29268
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29268
Test case

Compiling the test case with "-Wshadow" gives:

shadow.cpp: In instantiation of 'void bar<T>::baz() [with T = int]':
shadow.cpp:4:17:   required from 'void bar<T>::qux() [with T = int]'
shadow.cpp:13:21:   required from here
shadow.cpp:6:21: warning: declaration of 'foo' shadows a global declaration
[-Wshadow]
shadow.cpp:9:5: warning: shadowed declaration is here [-Wshadow]

Observed with 4.4.6, 4.6.1 and 4.7.2.

Note: "private" is not necessary to trigger the warning, it's just there to
show it occurs even with "private".

The warning seems strange because the supposedly shadowed variable is declared
after the shadowing one. (I assume that's because of the processing done during
instantiation.) It's annoying because it means that an identifier used in a
template defined in some header, even in a local scope in a private method is
"poisoned" when used anywhere else with -Wshadow.


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

end of thread, other threads:[~2015-04-01 21:38 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-24 21:11 [Bug c++/56100] New: spurious -Wshadow warning with local variable in template class f.heckenbach@fh-soft.de
2013-01-24 21:15 ` [Bug c++/56100] " pinskia at gcc dot gnu.org
2013-01-24 21:25 ` f.heckenbach@fh-soft.de
2015-03-31 11:19 ` paolo.carlini at oracle dot com
2015-03-31 13:29 ` jason at gcc dot gnu.org
2015-03-31 14:23 ` paolo.carlini at oracle dot com
2015-04-01 21:28 ` paolo at gcc dot gnu.org
2015-04-01 21:38 ` paolo.carlini at oracle 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).