https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95944
Bug ID: 95944 Summary: Concept diagnostic has multiple copies of irrelevant type and displays correct type incorrectly Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: barry.revzin at gmail dot com Target Milestone: --- Consider the following heavily reduced, and incorrect, attempt at an iterator: #include <ranges> template <typename T> struct range { struct iterator { using reference = T; using value_type = T; auto operator*() -> T; }; }; static_assert(std::indirectly_readable<range<int>::iterator>); This fails to meet the requirements of indirectly_readable because operator*() needs to be const. This is the diagnostic I get from gcc trunk: source>:13:20: error: static assertion failed 13 | static_assert(std::indirectly_readable<range<int>::iterator>); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <source>:13:20: note: constraints not satisfied In file included from /opt/compiler-explorer/gcc-10.1.0/include/c++/10.1.0/bits/stl_iterator_base_types.h:71, from /opt/compiler-explorer/gcc-10.1.0/include/c++/10.1.0/iterator:61, from /opt/compiler-explorer/gcc-10.1.0/include/c++/10.1.0/ranges:44, from <source>:1: /opt/compiler-explorer/gcc-10.1.0/include/c++/10.1.0/bits/iterator_concepts.h:446:13: required for the satisfaction of '__indirectly_readable_impl<typename std::remove_cv<typename std::remove_reference<_Tp>::type>::type>' [with _Tp = range<int>::iterator<int>] /opt/compiler-explorer/gcc-10.1.0/include/c++/10.1.0/bits/iterator_concepts.h:446:42: in requirements with 'const _In __in' [with _Tp = range<int>::iterator<int>; _Tp = range<int>::iterator<int>; _In = range<int>::iterator<int>] /opt/compiler-explorer/gcc-10.1.0/include/c++/10.1.0/bits/iterator_concepts.h:451:4: note: the required expression '* __in' is invalid 451 | { *__in } -> same_as<iter_reference_t<_In>>; | ^~~~~ /opt/compiler-explorer/gcc-10.1.0/include/c++/10.1.0/bits/iterator_concepts.h:452:21: note: the required expression 'std::ranges::__cust::iter_move(__in)' is invalid 452 | { ranges::iter_move(__in) } -> same_as<iter_rvalue_reference_t<_In>>; | ~~~~~~~~~~~~~~~~~^~~~~~ cc1plus: note: set '-fconcepts-diagnostics-depth=' to at least 2 for more detail Compiler returned: 1 There are two especially important lines in this diagnostic: the one that indicates the failed expression and the one that indicates the type of it. The one that indicates the types is this one: /opt/compiler-explorer/gcc-10.1.0/include/c++/10.1.0/bits/iterator_concepts.h:446:42: in requirements with 'const _In __in' [with _Tp = range<int>::iterator<int>; _Tp = range<int>::iterator<int>; _In = range<int>::iterator<int>] There is only one type in the requirement (_In) but the description starts with some type _Tp. And then we get _Tp a second time, before finally getting to _In. _In is also displayed incorrectly: it is shown as range<int>::iterator<int> when it should be range<int>::iterator. Ideally this line looks closer to: /opt/compiler-explorer/gcc-10.1.0/include/c++/10.1.0/bits/iterator_concepts.h:446:42: in requirements with 'const _In __in' [with _In = range<int>::iterator]