[llvm-bugs] [Bug 40379] New: Too much STL in error output

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Jan 19 09:12:02 PST 2019


https://bugs.llvm.org/show_bug.cgi?id=40379

            Bug ID: 40379
           Summary: Too much STL in error output
           Product: clang
           Version: 6.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: jg at jguk.org
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

Hello

Could the STL template output be reduced in build errors? Even as an option to
switch off for known STL, it's just a lot more than we ever need. I really
don't know or need to care what allocator is in use within an STL container.

#include <string>
int main()
{
    std::string str("hello ");
    std::size_t s = str.find(" ");
    str.erase(s, str.end());
}



It currently is roughly double that of CLANG. Although I think can reasonably
get down to 8 lines with candidate suggestions. Output included below, and an
example of something more brief.


The output I expected:

$ clang++ -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::string::erase(std::size_t&, std::string::iterator)’
     str.erase(s, str.end());
         ^
candidates are:
    std::string& std::string::erase(size_type index = 0, size_type count =
npos)
    std::string::iterator std::string::erase(const_iterator first,
const_iterator last)
    std::string::iterator std::string::erase(const_iterator position)



Current output from my clang 6, which appears similar to clang trunk on
godbolt.org


$ 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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190119/64d34e71/attachment.html>


More information about the llvm-bugs mailing list