[Bug libstdc++/35637] New: tr1::function fails with const member function pointer

gcc at david dot osborn dot name gcc-bugzilla@gcc.gnu.org
Wed Mar 19 10:37:00 GMT 2008


The following program fails under GCC 4.3.0 in pedantic mode, but works under
4.2.3.

#include <tr1/functional>
struct S
{
        void F() const {}
};
int main()
{
        std::tr1::function<void (S *)> a(&S::F); // doesn't work
        std::tr1::function<void (S *)> b(std::mem_fun(&S::F)); // works
}

g++ -c -pedantic test.cpp
...
c:/devel/mingw/lib/gcc/../../include/c++/4.3.0/tr1_impl/type_traits:320: error:
ignoring 'const' qualifiers added to function type 'void ()()const'

I think the problem has to do with the way the signature gets decomposed.  It
starts off as void(S::*)()const.  Next, tr1::is_member_function_pointer removes
S::*, yielding void()()const.  Finally, tr1::is_function calls remove_cv, which
produces the above error.


-- 
           Summary: tr1::function fails with const member function pointer
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gcc at david dot osborn dot name
  GCC host triplet: i686-pc-mingw32


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



More information about the Gcc-bugs mailing list