From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30117 invoked by alias); 3 Feb 2015 09:29:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 30040 invoked by uid 48); 3 Feb 2015 09:28:55 -0000 From: "antoshkka at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/64913] New: basic_string fails to use custom allocator Date: Tue, 03 Feb 2015 09:29:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: antoshkka at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-02/txt/msg00192.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64913 Bug ID: 64913 Summary: basic_string fails to use custom allocator Product: gcc Version: 5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: antoshkka at gmail dot com Consider the following example: template struct my_allocator : std::allocator {}; typedef std::basic_string< char , std::char_traits , my_allocator > my_string; my_string s1; my_string s2(static_cast(s1)); // Oops Attempt to move construct my_string produces the following error: /home/trippels/gcc_test/usr/local/include/c++/5.0.0/bits/basic_string.h: In instantiation of ???std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&) [with _CharT = char; _Traits = std::char_traits; _Alloc = my_allocator]???: ../boost/lexical_cast.hpp:45:16: required from ???Target boost::lexical_cast(const Source&) [with Target = std::__cxx11::basic_string, my_allocator >; Source = std::__cxx11::basic_string, my_allocator >]??? ../libs/lexical_cast/test/lexical_cast_test.cpp:510:5: required from here /home/trippels/gcc_test/usr/local/include/c++/5.0.0/bits/basic_string.h:475:73: error: no matching function for call to ???std::__cxx11::basic_string, my_allocator >::_Alloc_hider::_Alloc_hider(std::__cxx11::basic_string, my_allocator >::pointer, std::remove_reference&>::type)??? : _M_dataplus(_M_local_data(), std::move(__str._M_get_allocator())) ^ /home/trippels/gcc_test/usr/local/include/c++/5.0.0/bits/basic_string.h:108:2: note: candidate: std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_Alloc_hider::_Alloc_hider(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::pointer, const _Alloc&) [with _CharT = char; _Traits = std::char_traits; _Alloc = my_allocator; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::pointer = char*] _Alloc_hider(pointer __dat, const _Alloc& __a = _Alloc()) ^ /home/trippels/gcc_test/usr/local/include/c++/5.0.0/bits/basic_string.h:108:2: note: no known conversion for argument 2 from ???std::remove_reference&>::type {aka std::allocator}??? to ???const my_allocator&??? /home/trippels/gcc_test/usr/local/include/c++/5.0.0/bits/basic_string.h:106:14: note: candidate: std::__cxx11::basic_string, my_allocator >::_Alloc_hider::_Alloc_hider(const std::__cxx11::basic_string, my_allocator >::_Alloc_hider&) struct _Alloc_hider : allocator_type // TODO check __is_final ^ /home/trippels/gcc_test/usr/local/include/c++/5.0.0/bits/basic_string.h:106:14: note: candidate expects 1 argument, 2 provided /home/trippels/gcc_test/usr/local/include/c++/5.0.0/bits/basic_string.h:106:14: note: candidate: std::__cxx11::basic_string, my_allocator >::_Alloc_hider::_Alloc_hider(std::__cxx11::basic_string, my_allocator >::_Alloc_hider&&) /home/trippels/gcc_test/usr/local/include/c++/5.0.0/bits/basic_string.h:106:14: note: candidate expects 1 argument, 2 provided /home/trippels/gcc_test/usr/local/include/c++/5.0.0/bits/basic_string.h: In instantiation of ???std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&) [with _CharT = wchar_t; _Traits = std::char_traits; _Alloc = my_allocator]???: ../boost/lexical_cast.hpp:45:16: required from ???Target boost::lexical_cast(const Source&) [with Target = std::__cxx11::basic_string, my_allocator >; Source = std::__cxx11::basic_string, my_allocator >]??? ../libs/lexical_cast/test/lexical_cast_test.cpp:532:5: required from here /home/trippels/gcc_test/usr/local/include/c++/5.0.0/bits/basic_string.h:475:73: error: no matching function for call to ???std::__cxx11::basic_string, my_allocator >::_Alloc_hider::_Alloc_hider(std::__cxx11::basic_string, my_allocator >::pointer, std::remove_reference&>::type)??? : _M_dataplus(_M_local_data(), std::move(__str._M_get_allocator())) ^ /home/trippels/gcc_test/usr/local/include/c++/5.0.0/bits/basic_string.h:108:2: note: candidate: std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_Alloc_hider::_Alloc_hider(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::pointer, const _Alloc&) [with _CharT = wchar_t; _Traits = std::char_traits; _Alloc = my_allocator; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::pointer = wchar_t*] _Alloc_hider(pointer __dat, const _Alloc& __a = _Alloc()) ^ /home/trippels/gcc_test/usr/local/include/c++/5.0.0/bits/basic_string.h:108:2: note: no known conversion for argument 2 from ???std::remove_reference&>::type {aka std::allocator}??? to ???const my_allocator&??? /home/trippels/gcc_test/usr/local/include/c++/5.0.0/bits/basic_string.h:106:14: note: candidate: std::__cxx11::basic_string, my_allocator >::_Alloc_hider::_Alloc_hider(const std::__cxx11::basic_string, my_allocator >::_Alloc_hider&) struct _Alloc_hider : allocator_type // TODO check __is_final ^ /home/trippels/gcc_test/usr/local/include/c++/5.0.0/bits/basic_string.h:106:14: note: candidate expects 1 argument, 2 provided /home/trippels/gcc_test/usr/local/include/c++/5.0.0/bits/basic_string.h:106:14: note: candidate: std::__cxx11::basic_string, my_allocator >::_Alloc_hider::_Alloc_hider(std::__cxx11::basic_string, my_allocator >::_Alloc_hider&&) /home/trippels/gcc_test/usr/local/include/c++/5.0.0/bits/basic_string.h:106:14: note: candidate expects 1 argument, 2 provided