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

            Bug ID: 89326
           Summary: [RFE] Highlight `required from here` in compile-error
                    output
           Product: gcc
           Version: 8.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: Hi-Angel at yandex dot ru
  Target Milestone: ---

Compile-errors of constructors and templates can give a lot of output. Usually
the first thing in debugging is to figure out where the offending code is used.
This place in output is marked with `required from here`, but it's very hard to
find the magic words in the output, even more so given there are sentences
"required from" without "here" that go along the call stack.

Usually just below the "required from here" is a highlighted word "error", but
it often appears in other places as well.

# Steps to reproduce (in terms of terminal commands):

    $ cat test.cpp
    #include <list>

    struct NoCopy {
        NoCopy(const NoCopy&) = delete;
        NoCopy(NoCopy&&)      = default;
    };

    int main() {
        // Child ch{{}};
        std::list<NoCopy> l = {NoCopy{}};
    }
    ╭─constantine@constantine-N61Ja  /tmp ‹node-›  ‹› 
    ╰─$ g++ test.cpp
    In file included from
/usr/include/c++/8.2.1/x86_64-pc-linux-gnu/bits/c++allocator.h:33,
                     from /usr/include/c++/8.2.1/bits/allocator.h:46,
                     from /usr/include/c++/8.2.1/list:61,
                     from test.cpp:1:
    /usr/include/c++/8.2.1/ext/new_allocator.h: In instantiation of ‘void
__gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = NoCopy;
_Args = {const NoCopy&}; _Tp = std::_List_node<NoCopy>]’:
    /usr/include/c++/8.2.1/bits/alloc_traits.h:475:4:   required from ‘static
void std::allocator_traits<std::allocator<_Tp1>
>::construct(std::allocator_traits<std::allocator<_Tp1> >::allocator_type&,
_Up*, _Args&& ...) [with _Up = NoCopy; _Args = {const NoCopy&}; _Tp =
std::_List_node<NoCopy>; std::allocator_traits<std::allocator<_Tp1>
>::allocator_type = std::allocator<std::_List_node<NoCopy> >]’
    /usr/include/c++/8.2.1/bits/stl_list.h:645:33:   required from
‘std::__cxx11::list<_Tp, _Alloc>::_Node* std::__cxx11::list<_Tp,
_Alloc>::_M_create_node(_Args&& ...) [with _Args = {const NoCopy&}; _Tp =
NoCopy; _Alloc = std::allocator<NoCopy>; std::__cxx11::list<_Tp, _Alloc>::_Node
= std::_List_node<NoCopy>]’
    /usr/include/c++/8.2.1/bits/stl_list.h:1903:10:   required from ‘void
std::__cxx11::list<_Tp, _Alloc>::_M_insert(std::__cxx11::list<_Tp,
_Alloc>::iterator, _Args&& ...) [with _Args = {const NoCopy&}; _Tp = NoCopy;
_Alloc = std::allocator<NoCopy>; std::__cxx11::list<_Tp, _Alloc>::iterator =
std::_List_iterator<NoCopy>]’
    /usr/include/c++/8.2.1/bits/stl_list.h:1235:4:   required from ‘void
std::__cxx11::list<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {const
NoCopy&}; _Tp = NoCopy; _Alloc = std::allocator<NoCopy>]’
    /usr/include/c++/8.2.1/bits/stl_list.h:1832:6:   required from ‘void
std::__cxx11::list<_Tp, _Alloc>::_M_initialize_dispatch(_InputIterator,
_InputIterator, std::__false_type) [with _InputIterator = const NoCopy*; _Tp =
NoCopy; _Alloc = std::allocator<NoCopy>]’
    /usr/include/c++/8.2.1/bits/stl_list.h:769:9:   required from
‘std::__cxx11::list<_Tp, _Alloc>::list(std::initializer_list<_Tp>, const
allocator_type&) [with _Tp = NoCopy; _Alloc = std::allocator<NoCopy>;
std::__cxx11::list<_Tp, _Alloc>::allocator_type = std::allocator<NoCopy>]’
    test.cpp:10:36:   required from here
    /usr/include/c++/8.2.1/ext/new_allocator.h:136:4: error: use of deleted
function ‘NoCopy::NoCopy(const NoCopy&)’
      { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    test.cpp:4:5: note: declared here
         NoCopy(const NoCopy&) = delete;

# Expected

"required from here" is highlighted with some color

# Actual

"required from here" is of the same font/color as the rest of the text.

Reply via email to