https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88512
Bug ID: 88512 Summary: Too much STL in error output Product: gcc Version: 8.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: jg at jguk dot org Target Milestone: --- Hello Could the STL template output be reduced? It currently is roughly double that of CLANG. Although I think can reasonably get down to 3 lines. Output included below, and an example of something more brief. // g++ -Wall -o stl_string stl_string.cpp #include <string> int main() { std::string str("hello "); std::size_t s = str.find(" "); str.erase(s, str.end()); } Expected output something similar to the following expected stl_string.cpp: In function ‘int main()’: stl_string.cpp:10:15: error: invalid conversion from ‘std::size_t’ ’const_iterator’ std::string erase() Actual output: $ g++ -Wall -o stl_string stl_string.cpp stl_string.cpp: In function ‘int main()’: stl_string.cpp:7:27: error: no matching function for call to ‘std::__cxx11::basic_string<char>::erase(std::size_t&, std::__cxx11::basic_string<char>::iterator)’ str.erase(s, str.end()); ^ In file included from /usr/include/c++/7/string:52:0, from stl_string.cpp:2: /usr/include/c++/7/bits/basic_string.h:1779:7: note: candidate: std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::erase(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] erase(size_type __pos = 0, size_type __n = npos) ^~~~~ /usr/include/c++/7/bits/basic_string.h:1779:7: note: no known conversion for argument 2 from ‘std::__cxx11::basic_string<char>::iterator {aka __gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >}’ to ‘std::__cxx11::basic_string<char>::size_type {aka long unsigned int}’ /usr/include/c++/7/bits/basic_string.h:1798:7: note: candidate: std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::iterator std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::erase(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::__const_iterator) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::iterator = __gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >; typename __gnu_cxx::__alloc_traits<typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_CharT>::other>::pointer = char*; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::__const_iterator = __gnu_cxx::__normal_iterator<const char*, std::__cxx11::basic_string<char> >; typename __gnu_cxx::__alloc_traits<typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_CharT>::other>::const_pointer = const char*] erase(__const_iterator __position) ^~~~~ /usr/include/c++/7/bits/basic_string.h:1798:7: note: candidate expects 1 argument, 2 provided /usr/include/c++/7/bits/basic_string.h:1817:7: note: candidate: std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::iterator std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::erase(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::__const_iterator, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::__const_iterator) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::iterator = __gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >; typename __gnu_cxx::__alloc_traits<typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_CharT>::other>::pointer = char*; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::__const_iterator = __gnu_cxx::__normal_iterator<const char*, std::__cxx11::basic_string<char> >; typename __gnu_cxx::__alloc_traits<typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_CharT>::other>::const_pointer = const char*] erase(__const_iterator __first, __const_iterator __last) ^~~~~ /usr/include/c++/7/bits/basic_string.h:1817:7: note: no known conversion for argument 1 from ‘std::size_t {aka long unsigned int}’ to ‘std::__cxx11::basic_string<char>::__const_iterator {aka __gnu_cxx::__normal_iterator<const char*, std::__cxx11::basic_string<char> >}’ CLANG: $ clang -Wall -o stl_string stl_string.cpp stl_string.cpp:7:9: error: no matching member function for call to 'erase' str.erase(s, str.end()); ~~~~^~~~~ /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/bits/basic_string.h:1789:7: note: candidate function not viable: no known conversion from 'std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::iterator' (aka '__normal_iterator<char *, std::__cxx11::basic_string<char> >') to 'std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::size_type' (aka 'unsigned long') for 2nd argument erase(size_type __pos = 0, size_type __n = npos) ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/bits/basic_string.h:1827:7: note: candidate function not viable: no known conversion from 'std::size_t' (aka 'unsigned long') to 'std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::__const_iterator' (aka '__normal_iterator<const char *, std::__cxx11::basic_string<char> >') for 1st argument erase(__const_iterator __first, __const_iterator __last) ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/bits/basic_string.h:1808:7: note: candidate function not viable: requires single argument '__position', but 2 arguments were provided erase(__const_iterator __position) ^ 1 error generated.