-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
<algorithm>
: Fix bogus pointer arithmetic with integer-class
#5091
base: main
Are you sure you want to change the base?
<algorithm>
: Fix bogus pointer arithmetic with integer-class
#5091
Conversation
auto vw = views::iota(I{}, static_cast<I>(ranges::size(a))) | ||
| views::transform([&a](I i) -> auto& { return a[static_cast<size_t>(i)]; }); | ||
|
||
static_assert(three_way_comparable<ranges::iterator_t<ranges::iota_view<I>>>); // TRANSITION, /permissive |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really weird. It seems that MSVC doesn't evaluate concept specializations as quickly as required in permissive modes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the last bit of the error log:
D:\build\out\inc\__msvc_ranges_to.hpp(865): note: while evaluating concept 'three_way_comparable<std::ranges::_Ioterator<signed char>,std::partial_ordering>'
D:\build\out\inc\__msvc_ranges_to.hpp(865): error C2131: expression did not evaluate to a constant
D:\build\out\inc\__msvc_ranges_to.hpp(865): note: failure was caused by a read of an uninitialized symbol
D:\build\out\inc\__msvc_ranges_to.hpp(865): note: see usage of 'std::three_way_comparable<std::ranges::_Ioterator<_Wi>,std::partial_ordering>'
"C2131 while evaluating meow
... see usage of meow
" generally suggests constraint recursion, which is not that unusual in permissive mode. The fact the overload resolution sees "extra" friend overloads that ought to be hidden can easily trigger constraint recursion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some tweaks that I'll apply.
auto vw = views::iota(I{}, static_cast<I>(ranges::size(a))) | ||
| views::transform([&a](I i) -> auto& { return a[static_cast<size_t>(i)]; }); | ||
|
||
static_assert(three_way_comparable<ranges::iterator_t<ranges::iota_view<I>>>); // TRANSITION, /permissive |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the last bit of the error log:
D:\build\out\inc\__msvc_ranges_to.hpp(865): note: while evaluating concept 'three_way_comparable<std::ranges::_Ioterator<signed char>,std::partial_ordering>'
D:\build\out\inc\__msvc_ranges_to.hpp(865): error C2131: expression did not evaluate to a constant
D:\build\out\inc\__msvc_ranges_to.hpp(865): note: failure was caused by a read of an uninitialized symbol
D:\build\out\inc\__msvc_ranges_to.hpp(865): note: see usage of 'std::three_way_comparable<std::ranges::_Ioterator<_Wi>,std::partial_ordering>'
"C2131 while evaluating meow
... see usage of meow
" generally suggests constraint recursion, which is not that unusual in permissive mode. The fact the overload resolution sees "extra" friend overloads that ought to be hidden can easily trigger constraint recursion.
By using
ptrdiff_t
when the related value is guaranteed to be small enough and/or used in pointer arithmetic. Fixes #2885.