Bug 29515 - error: forming reference to reference type X.
Summary: error: forming reference to reference type X.
Status: RESOLVED DUPLICATE of bug 7412
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 4.1.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2006-10-19 11:53 UTC by Pawel Sikora
Modified: 2006-10-19 23:29 UTC (History)
7 users (show)

See Also:
Host:
Target: x86_64-linux
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
testcase (240 bytes, text/plain)
2006-10-19 11:54 UTC, Pawel Sikora
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Pawel Sikora 2006-10-19 11:53:32 UTC
comeau reports no error, and with stlport5 testcase works fine.

$ g++ -I/usr/include/stlport main.cpp -o main -lstlport && ./main
Hello 1
Hello 2

with libstdc++ i get:

$ g++ main.cpp -o main && ./main

/usr/include/c++/4.1.2/bits/stl_function.h: In instantiation of &#8216;std::binder2nd<std::pointer_to_binary_function<int, const std::string&, void> >&#8217;:
main.cpp:13:   instantiated from here
/usr/include/c++/4.1.2/bits/stl_function.h:435: error: forming reference to reference type &#8216;const std::string&&#8217;
/usr/include/c++/4.1.2/bits/stl_function.h: In function &#8216;std::binder2nd<_Operation> std::bind2nd(const _Operation&, const _Tp&) [with _Operation = std::pointer_to_binary_function<int, const std::string&, void>, _Tp = std::basic_string<char, std::char_traits<char>, std::allocator<char> >]&#8217;:
main.cpp:13:   instantiated from here
/usr/include/c++/4.1.2/bits/stl_function.h:455: error: no matching function for call to &#8216;std::binder2nd<std::pointer_to_binary_function<int, const std::string&, void> >::binder2nd(const std::pointer_to_binary_function<int, const std::string&, void>&, const std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)&#8217;
/usr/include/c++/4.1.2/bits/stl_function.h:429: note: candidates are: std::binder2nd<std::pointer_to_binary_function<int, const std::string&, void> >::binder2nd(const std::binder2nd<std::pointer_to_binary_function<int, const std::string&, void> >&)
Comment 1 Pawel Sikora 2006-10-19 11:54:53 UTC
Created attachment 12461 [details]
testcase
Comment 2 Paolo Carlini 2006-10-19 13:10:51 UTC
This is a well knows issue with the current standard binders, see, for example:

  http://gcc.gnu.org/ml/libstdc++/2000-06/msg00210.html

It is possible to extend the implementation, but the real way to go is moving to the new generalized bind facility, which will be in C++0x and we are already providing as part of our tr1 delivery. It would be (modulo tr1 namespace decorations...):

  bind(std::ptr_fun( print ), _1, str)
Comment 3 Andrew Pinski 2006-10-19 14:51:52 UTC
Actually this is valid C++ via DR 106.
Reopening to ...
Comment 4 Andrew Pinski 2006-10-19 14:52:28 UTC
To close as a dup of bug 7412.

*** This bug has been marked as a duplicate of 7412 ***
Comment 5 Paolo Carlini 2006-10-19 23:29:44 UTC
Ah, interesting! Therefore, if I understand correctly DR 106, when the C++ front-end will implement the resolution, this kind of bind2nd usage will magically start working without changing at all the library... On the other hand, Bjarne' observation in DR 106 is also interesting, because maintains that the library is mainly at fault for the binders... and this is already fixed in tr1::bind! Making progress everywhere!