[Bug libstdc++/35569] New: std::[tr1::]bind result functor doesn't accept rvalues

View: New views
13 Messages — Rating Filter:   Alert me  

[Bug libstdc++/35569] New: std::[tr1::]bind result functor doesn't accept rvalues

by Bugzilla from gcc-bugzilla@gcc.gnu.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The following code doesn't compile with gcc-4.3.0 on c++0x mode:

using std;
using std::placeholders;
bind(multiplies<int>(),4,_1)(5);

g++ outputs:

teste.cpp:2: error: no match for call to ‘(std::_Bind<std::multiplies<int>
()(st
d::_Placeholder<1>, int)>) (int)’
/usr/local/lib/gcc/i686-pc-linux-gnu/4.3.0/../../../../include/c++/4.3.0/tr1_imp
l/functional:1189: note: candidates are: typename std::result_of<_Functor
()(typ
ename std::result_of<std::_Mu<_Bound_args, std::is_bind_expression::value,
(std:
:is_placeholder::value > 0)> ()(_Bound_args, std::tuple<_UElements ...>)>::type
...)>::type std::_Bind<_Functor ()(_Bound_args ...)>::operator()(_Args& ...)
[wi
th _Args = int, _Functor = std::multiplies<int>, _Bound_args =
std::_Placeholder
<1>, int]
/usr/local/lib/gcc/i686-pc-linux-gnu/4.3.0/../../../../include/c++/4.3.0/tr1_imp
l/functional:1200: note:                 typename std::result_of<const _Functor
()(typename std::result_of<std::_Mu<_Bound_args,
std::is_bind_expression::value,
 (std::is_placeholder::value > 0)> ()(_Bound_args, std::tuple<_UElements
...>)>:
:type ...)>::type std::_Bind<_Functor ()(_Bound_args ...)>::operator()(_Args&
..
.) const [with _Args = int, _Functor = std::multiplies<int>, _Bound_args =
std::
_Placeholder<1>, int]
/usr/local/lib/gcc/i686-pc-linux-gnu/4.3.0/../../../../include/c++/4.3.0/tr1_imp
l/functional:1212: note:                 typename std::result_of<volatile
_Funct
or ()(typename std::result_of<std::_Mu<_Bound_args,
std::is_bind_expression::val
ue, (std::is_placeholder::value > 0)> ()(_Bound_args, std::tuple<_UElements
...>
)>::type ...)>::type std::_Bind<_Functor ()(_Bound_args
...)>::operator()(_Args&
 ...) volatile [with _Args = int, _Functor = std::multiplies<int>, _Bound_args
=
 std::_Placeholder<1>, int]
/usr/local/lib/gcc/i686-pc-linux-gnu/4.3.0/../../../../include/c++/4.3.0/tr1_imp
l/functional:1225: note:                 typename std::result_of<const volatile
_Functor ()(typename std::result_of<std::_Mu<_Bound_args,
std::is_bind_expressio
n::value, (std::is_placeholder::value > 0)> ()(_Bound_args,
std::tuple<_UElement
s ...>)>::type ...)>::type std::_Bind<_Functor ()(_Bound_args
...)>::operator()(
_Args& ...) const volatile [with _Args = int, _Functor = std::multiplies<int>,
_
Bound_args = std::_Placeholder<1>, int]

It seems that std::_Bind operator() doesn't accept rvalues. Maybe the arguments
should be passed by rvalue-references and std::forward'ed to the underlying
function (or functor).


--
           Summary: std::[tr1::]bind result functor doesn't accept rvalues
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rodolfo at rodsoft dot org


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


[Bug libstdc++/35569] [c++0x] std::bind result functor doesn't accept rvalues

by Bugzilla from gcc-bugzilla@gcc.gnu.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



--

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2008-10-02 17:27:55
               date|                            |
            Summary|std::[tr1::]bind result     |[c++0x] std::bind result
                   |functor doesn't accept      |functor doesn't accept
                   |rvalues                     |rvalues


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


[Bug libstdc++/35569] [c++0x] std::bind result functor doesn't accept rvalues

by Bugzilla from gcc-bugzilla@gcc.gnu.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



------- Comment #1 from paolo dot carlini at oracle dot com  2008-11-24 14:55 -------
*** Bug 38238 has been marked as a duplicate of this bug. ***


--

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fuscated at gmail dot com


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


[Bug libstdc++/35569] [c++0x] std::bind result functor doesn't accept rvalues

by Bugzilla from gcc-bugzilla@gcc.gnu.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



------- Comment #2 from jeff at schwabcenter dot com  2009-01-14 19:20 -------
I'm seeing the same thing with Boost.Bind (boost 1.37, GCC 4.2.1).

#include <boost/bind.hpp>
#include <functional>

using boost::bind;
using std::multiplies;

int main() {

    // Fine.
    int const lvalue = 5;
    bind(multiplies<int>(),4,_1)(lvalue);

    // Mistaken for a cast.
    bind(multiplies<int>(),4,_1)(5);
}


--


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


[Bug libstdc++/35569] [c++0x] std::bind result functor doesn't accept rvalues

by Bugzilla from gcc-bugzilla@gcc.gnu.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



------- Comment #3 from jwakely dot gcc at gmail dot com  2009-01-15 11:44 -------
I'm working on adding rvalue support to bind etc. but time is not on my side
recently.  I hope to make some more progress this weekend.


--


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


[Bug libstdc++/35569] [c++0x] std::bind result functor doesn't accept rvalues

by Bugzilla from gcc-bugzilla@gcc.gnu.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



------- Comment #4 from cfairles at gcc dot gnu dot org  2009-01-17 00:03 -------
*** Bug 38889 has been marked as a duplicate of this bug. ***


--

cfairles at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bangerth at dealii dot org


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


[Bug libstdc++/35569] [c++0x] std::bind result functor doesn't accept rvalues

by Bugzilla from gcc-bugzilla@gcc.gnu.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



------- Comment #5 from bangerth at dealii dot org  2009-01-17 01:41 -------
(In reply to comment #2)
> I'm seeing the same thing with Boost.Bind (boost 1.37, GCC 4.2.1).

boost.bind appears to work just fine for me, though!?

W.


--


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


[Bug libstdc++/35569] [c++0x] std::bind result functor doesn't accept rvalues

by Bugzilla from gcc-bugzilla@gcc.gnu.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



------- Comment #6 from paolo dot carlini at oracle dot com  2009-01-17 09:04 -------
Maybe this issue isn't sufficiently clarified in the audit. Unless I'm badly
mistaken (Jon, Chris will correct me), this is not a bug for a C++03 + TR1 bind
(indeed the testcases provided by Doug are rather clear about that). Only in
C++0x the specs say it must work. Of course implementations can also "fix" it
for C++03 + TR1, but this is not in general the way we are managing these
issues, we prefer leaving the TR1 version alone.


--


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


[Bug libstdc++/35569] [c++0x] std::bind result functor doesn't accept rvalues

by Bugzilla from gcc-bugzilla@gcc.gnu.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



------- Comment #7 from bangerth at dealii dot org  2009-01-18 03:58 -------
(In reply to comment #6)
> Maybe this issue isn't sufficiently clarified in the audit. Unless I'm badly
> mistaken (Jon, Chris will correct me), this is not a bug for a C++03 + TR1 bind
> (indeed the testcases provided by Doug are rather clear about that). Only in
> C++0x the specs say it must work. Of course implementations can also "fix" it
> for C++03 + TR1, but this is not in general the way we are managing these
> issues, we prefer leaving the TR1 version alone.

And it should work if you do -std=c++0x, which I believe (from the title of
the PR) is what the original intent was.

W.


--


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


[Bug libstdc++/35569] [c++0x] std::bind result functor doesn't accept rvalues

by Bugzilla from gcc-bugzilla@gcc.gnu.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



--

redi at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |jwakely dot gcc at gmail dot
                   |dot org                     |com
             Status|NEW                         |ASSIGNED


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


[Bug libstdc++/35569] [c++0x] std::bind result functor doesn't accept rvalues

by Bugzilla from gcc-bugzilla@gcc.gnu.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



------- Comment #8 from jwakely dot gcc at gmail dot com  2009-06-05 12:48 -------
I've got std::bind and friends working with rvalues, but bug 34022 means that
ugly workarounds are needed to work with rvalues of scalar types.  When Core DR
664 is ready and bug 34022 is fixed that won't be necessary.

Similar problems exist when invoking std::function with scalar rvalue
arguments.


--

jwakely dot gcc at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  BugsThisDependsOn|                            |34022


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


[Bug libstdc++/35569] [c++0x] std::bind result functor doesn't accept rvalues

by Bugzilla from gcc-bugzilla@gcc.gnu.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



------- Comment #9 from paolo dot carlini at oracle dot com  2009-11-11 13:19 -------
Jon, do you have any updated plans about this and related issues? I think it
would be nice if we could make progress on the C++0x <functional> for 4.5.0...


--

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |paolo dot carlini at oracle
                   |                            |dot com


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


[Bug libstdc++/35569] [c++0x] std::bind result functor doesn't accept rvalues

by Bugzilla from gcc-bugzilla@gcc.gnu.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



------- Comment #10 from redi at gcc dot gnu dot org  2009-11-11 14:05 -------
Sorry for the lack of progress, I'll take another crack at it this week and
report back on what I've got and what doesn't work.  If I can't finish it I'll
say so and unassign myself from this PR


--


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