https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79162
Bug ID: 79162 Summary: [7 Regression] [C++17] ambiguity in string assignment due to string_view overload Product: gcc Version: 7.0 Status: UNCONFIRMED Keywords: rejects-valid Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: redi at gcc dot gnu.org Target Milestone: --- #include <string> int main() { std::string s; s = {"abc", 1}; } This compiled with GCC 6, but with 7 gives: s.cc: In function ‘int main()’: s.cc:5:15: error: ambiguous overload for ‘operator=’ (operand types are ‘std::__cxx11::string {aka std::__cxx11::basic_string<char>}’ and ‘<brace-enclosed initializer list>’) s = {"abc", 1}; ^ In file included from /home/jwakely/gcc/7/include/c++/7.0.0/string:52:0, from s.cc:1: /home/jwakely/gcc/7/include/c++/7.0.0/bits/basic_string.h:627:7: note: candidate: std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>] operator=(const basic_string& __str) ^~~~~~~~ /home/jwakely/gcc/7/include/c++/7.0.0/bits/basic_string.h:680:7: note: candidate: std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>] operator=(basic_string&& __str) ^~~~~~~~ /home/jwakely/gcc/7/include/c++/7.0.0/bits/basic_string.h:747:7: note: candidate: std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::__sv_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::__sv_type = std::basic_string_view<char>] operator=(__sv_type __sv) ^~~~~~~~