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

            Bug ID: 114135
           Summary: Diagnostic missing useful information for ranges code
           Product: gcc
           Version: 13.1.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: ---

This is an example using Ranges:

#include <algorithm>
#include <ranges>
using namespace std;

int main() {
    auto rng = views::iota(0, 3);
    const auto [a, b] = * ranges::min_element(views::cartesian_product(rng,
rng));
    return 0;
}

This is an ill-formed program, the error given by gcc trunk is:

<source>:7:25: error: no match for 'operator*' (operand type is
'std::ranges::borrowed_iterator_t<std::ranges::cartesian_product_view<std::ranges::iota_view<int,
int>, std::ranges::iota_view<int, int> > >')
    7 |     const auto [a, b] = *
ranges::min_element(views::cartesian_product(rng, rng));
      |                        
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This is all correct. However, it would be more helpful in this case for the
reader to also note that the type
std::ranges::borrowed_iterator_t<that_whole_thing> is actually the type
std::ranges::dangling. Seeing "dangling" in the error message makes it a lot
easier to understand what the issue here actually is.
  • [Bug c++/114135] New: Diagnosti... barry.revzin at gmail dot com via Gcc-bugs

Reply via email to