This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/41825] New: useless -Wshadow warning on function argument in local class
- From: "msebor at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 25 Oct 2009 20:06:37 -0000
- Subject: [Bug c++/41825] New: useless -Wshadow warning on function argument in local class
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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