The warning on the code below isn't useful since the formal argument of foo()
named i cannot be referenced in the body of the local struct. I.e., there is
no potential for referring to it by mistake since doing so would be a hard
error.

$ cat t.cpp && g++ -c -Wshadow t.cpp
int foo (int i)
{
    struct {
        int bar (int i) { return i; }
    } s;

    return s.bar (i);
};
t.cpp: In member function ‘int foo(int)::<anonymous struct>::bar(int)’:
t.cpp:4: warning: declaration of ‘int i’ shadows a parameter
t.cpp:1: warning: shadowed declaration is here


-- 
           Summary: useless -Wshadow warning on function argument in local
                    class
           Product: gcc
           Version: 4.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: msebor at gmail dot com
 GCC build triplet: all
  GCC host triplet: all
GCC target triplet: all


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

Reply via email to