[Bug c++/89370] New: Output std::string in diagnostics instead of std::__cxx11::basic_string<_CharT, _Traits, _Alloc>

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Feb 15 18:58:00 GMT 2019


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89370

            Bug ID: 89370
           Summary: Output std::string in diagnostics instead of
                    std::__cxx11::basic_string<_CharT, _Traits, _Alloc>
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

Errors involving std::string are unreadable (see Bug 88512 comment 8). Nobody
cares that it's:

'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::iterator
std::__cxx11::basic_string<_CharT, _Traits,
_Alloc>::insert(std::__cxx11::basic_string<_CharT, _Traits,
_Alloc>::__const_iterator, _CharT) [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*]'
 1745 |       insert(__const_iterator __p, _CharT __c)
      |       ^~~~~~


The type std::__cxx11::basic_string<_CharT, _Traits, _Alloc> should be shown as
std::string. That alone makes it far more readable. And if we don't show it as
a template specialization maybe we don't need the entire "[with ...]" part at
all, but if we do need it, we should reduce it ...

I don't think expanding the return type or the __const_iterator type in the
"[with ...]" part is very useful:

std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::iterator =
__gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >;

std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::iterator =
__gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >;


And why on Earth is it telling us what the pointer and const_pointer types
are?! They don't appear in the member function signature at all!

typename __gnu_cxx::__alloc_traits<typename
__gnu_cxx::__alloc_traits<_Alloc>::rebind<_CharT>::other>::pointer = char*;

 typename __gnu_cxx::__alloc_traits<typename
__gnu_cxx::__alloc_traits<_Alloc>::rebind<_CharT>::other>::const_pointer =
const char*

Cool story bro. Those types are not relevant.


More information about the Gcc-bugs mailing list