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

           Summary: [4.5/4.6 Regression] [C++0x] bind<R>(x)(y, z) fails
           Product: gcc
           Version: 4.5.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: r...@gcc.gnu.org


Notice while working on PR 45893, this fails:

#include <functional>

struct f
{
  int operator()(int, int) { return 0; }
};

void test01()
{
  int i = 0;
  using namespace std::placeholders;
  std::bind<int>(f(), _1, _2)(i, i);
}

int main()
{
  test01();
  return 0;
}

In file included from bind.cc:1:0:
/home/redi/gcc/4.5/lib/gcc/x86_64-unknown-linux-gnu/4.5.2/../../../../include/c++/4.5.2/functional:
In member function ‘result_type std::_Bind_result<_Result, _Functor(_Bound_args
...)>::operator()(_Args&& ...) [with _Args = {int&, int&}, _Result = int,
_Functor = f, _Bound_args = {std::_Placeholder<1>, std::_Placeholder<2>},
result_type = int]’:
bind.cc:12:35:   instantiated from here
/home/redi/gcc/4.5/lib/gcc/x86_64-unknown-linux-gnu/4.5.2/../../../../include/c++/4.5.2/functional:1327:31:
error: no matching function for call to ‘forward(int&)’


The reason is a misplaced template parameter pack expansion:
              tuple<_Args...>(std::forward<_Args...>(__args)...),
                                                ^^^
It should be:
              tuple<_Args...>(std::forward<_Args>(__args)...),

This is a regression against the version of std::bind in 4.4

Reply via email to