Bug 29224 - -Wshadow causing warning in <tr1/functional>
Summary: -Wshadow causing warning in <tr1/functional>
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 4.0.1
: P3 minor
Target Milestone: 4.1.2
Assignee: Not yet assigned to anyone
URL:
Keywords:
: 29603 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-09-25 21:51 UTC by Howard Hinnant
Modified: 2006-10-26 09:30 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-09-25 21:55:42


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Howard Hinnant 2006-09-25 21:51:16 UTC
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
Comment 1 Paolo Carlini 2006-09-25 21:55:42 UTC
Thanks Howard.
Comment 2 paolo@gcc.gnu.org 2006-09-26 00:59:46 UTC
Subject: Bug 29224

Author: paolo
Date: Tue Sep 26 00:59:37 2006
New Revision: 117222

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=117222
Log:
2006-09-26  Howard Hinnant  <hhinnant@apple.com>

	PR libstdc++/29224
	* include/tr1/functional_iterate.h: Avoid -Wshadow warnings.

Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/tr1/functional_iterate.h

Comment 3 paolo@gcc.gnu.org 2006-09-26 01:00:06 UTC
Subject: Bug 29224

Author: paolo
Date: Tue Sep 26 00:59:53 2006
New Revision: 117223

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=117223
Log:
2006-09-26  Howard Hinnant  <hhinnant@apple.com>

	PR libstdc++/29224
	* include/tr1/functional_iterate.h: Avoid -Wshadow warnings.

Modified:
    branches/gcc-4_1-branch/libstdc++-v3/ChangeLog
    branches/gcc-4_1-branch/libstdc++-v3/include/tr1/functional_iterate.h

Comment 4 Paolo Carlini 2006-09-26 01:01:41 UTC
Fixed for 4.1.2.
Comment 5 Bernardo Innocenti 2006-10-26 09:30:14 UTC
*** Bug 29603 has been marked as a duplicate of this bug. ***