-
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
Fix handling of array rvalues for ranges::cbegin
and its friends
#3316
Fix handling of array rvalues for ranges::cbegin
and its friends
#3316
Conversation
I'm not sure about this; the standard says (for
They are also missing the very important Note 1 from
What this says to me is that |
We talked about this at the weekly maintainer meeting, and concluded that when WG21-P2278R4 updated the Standard, the Note that appears for @strega-nil-ms has volunteered to submit a editorial issue (or PR) to the C++ draft. Thanks Nicole! |
Submitted Draft-PR-6046. |
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.
Thanks for the bug-fix!
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.
Thanks for the PR!
noexcept(noexcept(_RANGES data(_RANGES _Possibly_const_range(_Val)))) { | ||
return _RANGES _As_const_pointer(_RANGES data(_RANGES _Possibly_const_range(_Val))); |
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.
No change requested: I observe that the noexcept
expression differs from the return
expression because _As_const_pointer
is unconditionally noexcept
- this is a reasonable shortcut for throughput.
I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed. |
Thanks again for finding and fixing this, so the implementations are consistent! 😻 🔍 ✅ |
When the argument is an rvalue of an array,
ranges::cbegin
,ranges::cend
,ranges::crbegin
, andranges::crend
should reject it with substitution failures, despite of whether the element type is complete or not. I think such requirements haven't been changed by P2278R4 (i.e. unchanged between C++20 and C++23).(On the other hand, if the argument is an lvalue of an array of an incomplete element type, the program is ill-formed, no diagnostic required.)
I originally discovered the bug of implementation in #3187 (comment), but hadn't determined how to fix it at that time.
Clang 15 is buggy - it fails to perform shortcut in concept substitution when using requires-clause. This is probably LLVM-55945 and fixed in Clang 16 (Godbolt link).
The current workaround is combining constraints into one concept and using the abbreviated syntax.