-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Open
Labels
bugzillaIssues migrated from bugzillaIssues migrated from bugzillac++20clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerclang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"conceptsC++20 conceptsC++20 concepts
Description
Bugzilla Link | 51918 |
Version | trunk |
OS | All |
CC | @zygoloid |
Extended Description
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);
});
}
Metadata
Metadata
Assignees
Labels
bugzillaIssues migrated from bugzillaIssues migrated from bugzillac++20clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerclang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"conceptsC++20 conceptsC++20 concepts
Type
Projects
Status
No status