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: unassig...@gcc.gnu.org

        ReportedBy: f.heckenb...@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.

Reply via email to