https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84087
Bug ID: 84087 Summary: string::assign problem with two arguments Product: gcc Version: 7.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: bseifert at gmx dot at Target Milestone: --- Created attachment 43267 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=43267&action=edit does not compile as expected >From C++14, string::assign can be called with two arguments: the string (1) and the position (2). The length (3) is optional. This worked in gcc 7.2.0. In 7.3.0 (with the updated libstdc++), the call with only 2 arguments does not work. gcc 7.3.0 was compiled with default settings in Windows 10 bash. The following line is used to compile main.cpp (attached): ~/gcc-7.3.0/bin/gcc main.cpp --std=c++14 The following error messages are returned: main.cpp: In function ‘int main()’: main.cpp:8:17: error: no matching function for call to ‘std::__cxx11::basic_string<char>::assign(std::__cxx11::string&, int)’ s.assign(s, 2); ^ In file included from /home/seifert/gcc-7.3.0/include/c++/7.3.0/string:52:0, from main.cpp:3: /home/seifert/gcc-7.3.0/include/c++/7.3.0/bits/basic_string.h:1345:7: note: candidate: std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::assign(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>] assign(const basic_string& __str) ^~~~~~ /home/seifert/gcc-7.3.0/include/c++/7.3.0/bits/basic_string.h:1345:7: note: candidate expects 1 argument, 2 provided /home/seifert/gcc-7.3.0/include/c++/7.3.0/bits/basic_string.h:1361:7: note: candidate: std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::assign(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>] assign(basic_string&& __str) ^~~~~~ /home/seifert/gcc-7.3.0/include/c++/7.3.0/bits/basic_string.h:1361:7: note: candidate expects 1 argument, 2 provided /home/seifert/gcc-7.3.0/include/c++/7.3.0/bits/basic_string.h:1384:7: note: candidate: std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::assign(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type = long unsigned int] assign(const basic_string& __str, size_type __pos, size_type __n) ^~~~~~ /home/seifert/gcc-7.3.0/include/c++/7.3.0/bits/basic_string.h:1384:7: note: candidate expects 3 arguments, 2 provided /home/seifert/gcc-7.3.0/include/c++/7.3.0/bits/basic_string.h:1400:7: note: candidate: std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::assign(const _CharT*, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type = long unsigned int] assign(const _CharT* __s, size_type __n) ^~~~~~ /home/seifert/gcc-7.3.0/include/c++/7.3.0/bits/basic_string.h:1400:7: note: no known conversion for argument 1 from ‘std::__cxx11::string {aka std::__cxx11::basic_string<char>}’ to ‘const char*’ /home/seifert/gcc-7.3.0/include/c++/7.3.0/bits/basic_string.h:1416:7: note: candidate: std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::assign(const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>] assign(const _CharT* __s) ^~~~~~ /home/seifert/gcc-7.3.0/include/c++/7.3.0/bits/basic_string.h:1416:7: note: candidate expects 1 argument, 2 provided /home/seifert/gcc-7.3.0/include/c++/7.3.0/bits/basic_string.h:1433:7: note: candidate: std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::assign(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type, _CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type = long unsigned int] assign(size_type __n, _CharT __c) ^~~~~~ /home/seifert/gcc-7.3.0/include/c++/7.3.0/bits/basic_string.h:1433:7: note: no known conversion for argument 1 from ‘std::__cxx11::string {aka std::__cxx11::basic_string<char>}’ to ‘std::__cxx11::basic_string<char>::size_type {aka long unsigned int}’ /home/seifert/gcc-7.3.0/include/c++/7.3.0/bits/basic_string.h:1451:9: note: candidate: template<class _InputIterator, class> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::assign(_InputIterator, _InputIterator) [with _InputIterator = _InputIterator; <template-parameter-2-2> = <template-parameter-1-2>; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>] assign(_InputIterator __first, _InputIterator __last) ^~~~~~ /home/seifert/gcc-7.3.0/include/c++/7.3.0/bits/basic_string.h:1451:9: note: template argument deduction/substitution failed: main.cpp:8:17: note: deduced conflicting types for parameter ‘_InputIterator’ (‘std::__cxx11::basic_string<char>’ and ‘int’) s.assign(s, 2); ^ In file included from /home/seifert/gcc-7.3.0/include/c++/7.3.0/string:52:0, from main.cpp:3: /home/seifert/gcc-7.3.0/include/c++/7.3.0/bits/basic_string.h:1461:7: note: candidate: std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::assign(std::initializer_list<_Tp>) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>] assign(initializer_list<_CharT> __l) ^~~~~~ /home/seifert/gcc-7.3.0/include/c++/7.3.0/bits/basic_string.h:1461:7: note: candidate expects 1 argument, 2 provided