The following test.cpp:
#include <tr1/functional>
struct A
{
void foo() {}
};
int main()
{
std::tr1::mem_fn(&A::foo);
}
compiled with:
g++ -Wshadow test.cpp
causes:
/usr/include/c++/4.0.0/tr1/functional_iterate.h: In constructor
'std::tr1::_Mem_fn<_Res (_Class::*)()>::_Mem_fn(_Res (_Class::*)()) [with _Res
= void, _Class = A]':
/usr/include/c++/4.0.0/tr1/functional:502: instantiated from
'std::tr1::_Mem_fn<_Res _Class::*> std::tr1::mem_fn(_Tp _Class::*) [with _Tp =
void ()(), _Class = A]'
test.cpp:10: instantiated from here
/usr/include/c++/4.0.0/tr1/functional_iterate.h:202: warning: declaration of
'__pmf' shadows a member of 'this'
The following patch will silence the warning:
$ svn diff
Index: libstdc++-v3/include/tr1/functional_iterate.h
===================================================================
--- libstdc++-v3/include/tr1/functional_iterate.h (revision 117204)
+++ libstdc++-v3/include/tr1/functional_iterate.h (working copy)
@@ -195,7 +195,7 @@
public:
typedef _Res result_type;
- explicit _Mem_fn(_Functor __pmf) : __pmf(__pmf) { }
+ explicit _Mem_fn(_Functor __pf) : __pmf(__pf) { }
// Handle objects
_Res
@@ -249,7 +249,7 @@
public:
typedef _Res result_type;
- explicit _Mem_fn(_Functor __pmf) : __pmf(__pmf) { }
+ explicit _Mem_fn(_Functor __pf) : __pmf(__pf) { }
// Handle objects
_Res
@@ -303,7 +303,7 @@
public:
typedef _Res result_type;
- explicit _Mem_fn(_Functor __pmf) : __pmf(__pmf) { }
+ explicit _Mem_fn(_Functor __pf) : __pmf(__pf) { }
// Handle objects
_Res
@@ -357,7 +357,7 @@
public:
typedef _Res result_type;
- explicit _Mem_fn(_Functor __pmf) : __pmf(__pmf) { }
+ explicit _Mem_fn(_Functor __pf) : __pmf(__pf) { }
// Handle objects
_Res
--
Summary: -Wshadow causing warning in <tr1/functional>
Product: gcc
Version: 4.0.1
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: libstdc++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: hhinnant at apple dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29224