[llvm-bugs] [Bug 51918] New: [concepts] improve diagnostics for range concept failures
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Sep 20 12:58:02 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=51918
Bug ID: 51918
Summary: [concepts] improve diagnostics for range concept
failures
Product: clang
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: C++2b
Assignee: unassignedclangbugs at nondot.org
Reporter: ldalessandro at gmail.com
CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk
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
https://godbolt.org/z/e9M9T3z5j, 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
https://en.cppreference.com/w/cpp/ranges/borrowed_iterator_t 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);
});
}
```
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210920/dc0db353/attachment.html>
More information about the llvm-bugs
mailing list