-
Notifications
You must be signed in to change notification settings - Fork 12.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
evaluation of constraints for std::ranges::views::drop() fails unnecessarily #46853
Comments
I narrowed it down to eager evaluation of constraints:
According to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97120#c1, evaluation should be lazy. |
This reduces to something interesting: Clang accepts:template <typename _Tp>
concept __member_begin = requires(_Tp __t) {
{__t.begin()};
};
template <typename _Tp>
concept nothing = requires(_Tp __t) {
{42};
};
template <typename _Tp>
requires __member_begin<_Tp> void __ranges_begin() {}
template <typename _Derived>
struct view_interface {
void foo() requires __member_begin<_Derived> {}
// void bar() requires nothing<decltype(__ranges_begin<_Derived>())> {}
};
struct drop_view : public view_interface<drop_view> {}; Uncomment the declaration of bar and clang rejects this. gcc is OK with both. If I understand it correctly, both gcc and clang agree that the direct use of a unsatisfied requires should just disable foo. The disagreement is about an indirect one, like in bar(). With gcc bar() is just disabled, but clang produces an error. Note that gcc rejects: template <typename _Tp>
concept __member_begin = requires(_Tp __t) {
{__t.begin()};
};
template <typename _Tp>
concept nothing = requires(_Tp __t) {
{42};
};
template <typename _Tp>
requires __member_begin<_Tp> void __ranges_begin() {}
template <typename _Derived>
struct view_interface {
void foo() requires __member_begin<_Derived> {}
void bar() requires nothing<decltype(__ranges_begin<_Derived>())> {}
};
struct drop_view : public view_interface<drop_view> {
void zed() {
this->bar();
}
}; |
This is indeed clang's bug: #50208 |
And this one and that are both dups of #44178 |
mentioned in issue #48855 |
This doesn't happen anymore, see https://godbolt.org/z/5fhnM3YTo. Also, on libc++, we haven't implemented |
It does not compile with clang trunk: https://godbolt.org/z/Prn9Kze64 |
Oh yes, you are right, sorry about that. https://godbolt.org/z/hsvoWM3je shows: Clang trunk / libstdc++: fails |
Which is now #44178 |
Duplicate of #44178. |
Extended Description
The test program
==== begin test program ====
==== end test program ====
Does not compile on clang, either with libc++ or libstdc++, failing on some enormously complicated constraints. gcc accepts it.
The text was updated successfully, but these errors were encountered: