This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/30566] New: -Wshadow warns about clashes between nested function parameters in C++
- From: "geoffk at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 23 Jan 2007 23:21:21 -0000
- Subject: [Bug c++/30566] New: -Wshadow warns about clashes between nested function parameters in C++
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The following program:
void f( int x )
{
class InnerClass
{
public:
static void g( int x )
{
// empty
}
};
}
produces a warning:
t.cc: In static member function 'static void f(int)::InnerClass::g(int)':
t.cc:7: warning: declaration of 'int x' shadows a parameter
t.cc:1: warning: shadowed declaration is here
But it would be invalid for any function in InnerClass to try and use the outer
"int x" (and in fact if you try it, you correctly get an error).
--
Summary: -Wshadow warns about clashes between nested function
parameters in C++
Product: gcc
Version: 4.2.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: minor
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: geoffk at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30566