<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [concepts] improve diagnostics for range concept failures"
   href="https://bugs.llvm.org/show_bug.cgi?id=51918">51918</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[concepts] improve diagnostics for range concept failures
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++2b
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>ldalessandro@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Clang produces some concepts diagnostics that are of limited use to the
programmer, particularly with respect to the ranges library.

In this case, I was playing around with proxy iterators and ran into
<a href="https://godbolt.org/z/e9M9T3z5j">https://godbolt.org/z/e9M9T3z5j</a>, which tells me that my iterator type fails the
borrowed_iterator_t requirement, however it gives me absolutely no information
about _why_. 

The borrowed_iterator_t is not a trivial concept, when I google for it I get
<a href="https://en.cppreference.com/w/cpp/ranges/borrowed_iterator_t">https://en.cppreference.com/w/cpp/ranges/borrowed_iterator_t</a> which is split
into two cases as:

    1) std::ranges::iterator_t<R> if R models borrowed_range,
std::ranges::dangling otherwise.
    2) std::ranges::subrange<std::ranges::iterator_t<R>> if R models
borrowed_range, std::ranges::dangling otherwise.

As a user I have no idea what to do at this point.

The reduced code I was looking at was

```
struct Broken {
    struct iterator {
        int i;
        auto operator*() const -> decltype(auto) {
            return std::tie(i);
        }
        auto operator++() -> decltype(auto) {
            ++i;
            return *this;
        }
        friend bool operator==(iterator const&, iterator const&) = default;
        friend auto operator<=>(iterator const&, iterator const&) = default;
    };

    auto begin() const -> iterator { return {}; }
    auto end() const -> iterator { return {}; }
};

int foo() {
    Broken r;
    std::ranges::for_each(r, [](auto t) { 
        auto [i] = t;
        printf("%d\n", i);
    });
}
```</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>