public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/50320] New: Calling tr1 binder with constant expression fails
@ 2011-09-07 12:42 martinhaefner at web dot de
  2011-09-07 12:58 ` [Bug libstdc++/50320] " redi at gcc dot gnu.org
  2011-09-07 12:59 ` redi at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: martinhaefner at web dot de @ 2011-09-07 12:42 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 50320
           Summary: Calling tr1 binder with constant expression fails
    Classification: Unclassified
           Product: gcc
           Version: 4.4.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: martinhaefner@web.de


The following code fragment does yield a compiler error:


#include <tr1/functional>

void f(int i)
{
   // do something
}

template<typename BinderT>
void call(BinderT b)
{
//   int i = 42; b(i);    // <--- would be ok
   b(42);                 // <--- compiler error
}

int main()
{
   call(std::tr1::bind(f, std::tr1::placeholders::_1));
   return 0;
}


mmes@ubuntu:~$ g++-4.4 bind.cpp
bind.cpp: In function ‘void call(BinderT) [with BinderT = std::tr1::_Bind<void
(*(std::tr1::_Placeholder<1>))(int)>]’:
bind.cpp:17:   instantiated from here
bind.cpp:12: error: no match for call to ‘(std::tr1::_Bind<void
(*(std::tr1::_Placeholder<1>))(int)>) (int)’
/usr/include/c++/4.4/tr1_impl/functional:1189: note: candidates are: typename
std::tr1::result_of<_Functor(typename
std::tr1::result_of<std::tr1::_Mu<_Bound_args,
std::tr1::is_bind_expression::value, (std::tr1::is_placeholder::value >
0)>(_Bound_args, std::tr1::tuple<_UElements ...>)>::type ...)>::type
std::tr1::_Bind<_Functor(_Bound_args ...)>::operator()(_Args& ...) [with _Args
= int, _Functor = void (*)(int), _Bound_args = std::tr1::_Placeholder<1>]
/usr/include/c++/4.4/tr1_impl/functional:1200: note:                 typename
std::tr1::result_of<const _Functor(typename
std::tr1::result_of<std::tr1::_Mu<_Bound_args,
std::tr1::is_bind_expression::value, (std::tr1::is_placeholder::value >
0)>(_Bound_args, std::tr1::tuple<_UElements ...>)>::type ...)>::type
std::tr1::_Bind<_Functor(_Bound_args ...)>::operator()(_Args& ...) const [with
_Args = int, _Functor = void (*)(int), _Bound_args = std::tr1::_Placeholder<1>]
/usr/include/c++/4.4/tr1_impl/functional:1212: note:                 typename
std::tr1::result_of<volatile _Functor(typename
std::tr1::result_of<std::tr1::_Mu<_Bound_args,
std::tr1::is_bind_expression::value, (std::tr1::is_placeholder::value >
0)>(_Bound_args, std::tr1::tuple<_UElements ...>)>::type ...)>::type
std::tr1::_Bind<_Functor(_Bound_args ...)>::operator()(_Args& ...) volatile
[with _Args = int, _Functor = void (*)(int), _Bound_args =
std::tr1::_Placeholder<1>]
/usr/include/c++/4.4/tr1_impl/functional:1225: note:                 typename
std::tr1::result_of<const volatile _Functor(typename
std::tr1::result_of<std::tr1::_Mu<_Bound_args,
std::tr1::is_bind_expression::value, (std::tr1::is_placeholder::value >
0)>(_Bound_args, std::tr1::tuple<_UElements ...>)>::type ...)>::type
std::tr1::_Bind<_Functor(_Bound_args ...)>::operator()(_Args& ...) const
volatile [with _Args = int, _Functor = void (*)(int), _Bound_args =
std::tr1::_Placeholder<1>]


While calling the binder with a variable works perfectly. I am expecting that
binding a constant expression also works (as done by boost binders).

Regards,
Martin


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug libstdc++/50320] Calling tr1 binder with constant expression fails
  2011-09-07 12:42 [Bug libstdc++/50320] New: Calling tr1 binder with constant expression fails martinhaefner at web dot de
@ 2011-09-07 12:58 ` redi at gcc dot gnu.org
  2011-09-07 12:59 ` redi at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2011-09-07 12:58 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-09-07 12:49:54 UTC ---
see PR 35569 and its duplicates such as PR 38238

I can't remember if this is even meant to work according to the TR1 spec -
we've fixed it for std::bind, but not tr1::bind


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug libstdc++/50320] Calling tr1 binder with constant expression fails
  2011-09-07 12:42 [Bug libstdc++/50320] New: Calling tr1 binder with constant expression fails martinhaefner at web dot de
  2011-09-07 12:58 ` [Bug libstdc++/50320] " redi at gcc dot gnu.org
@ 2011-09-07 12:59 ` redi at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2011-09-07 12:59 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |DUPLICATE

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-09-07 12:56:49 UTC ---
TR1 says that tr1::bind returns a forwarding call wrapper, where "A forwarding
call wrapper is a call wrapper that can be called with an argument list t1, t2,
..., tN where each ti is an lvalue. The effect of calling a forwarding call
wrapper with one or more arguments that are rvalues is implementation defined."

So TR1 is pretty clear that it only needs to support lvalue arguments.

*** This bug has been marked as a duplicate of bug 35569 ***


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-09-07 12:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-07 12:42 [Bug libstdc++/50320] New: Calling tr1 binder with constant expression fails martinhaefner at web dot de
2011-09-07 12:58 ` [Bug libstdc++/50320] " redi at gcc dot gnu.org
2011-09-07 12:59 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).