public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/100824] ranges::size should treat the subexpression as an lvalue Date: Fri, 04 Jun 2021 14:59:55 +0000 [thread overview] Message-ID: <bug-100824-4-BT5wuTGwIE@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-100824-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100824 --- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>: https://gcc.gnu.org/g:ee9548b36a7f17e8a63585b58f340c93dcba95d8 commit r12-1214-gee9548b36a7f17e8a63585b58f340c93dcba95d8 Author: Jonathan Wakely <jwakely@redhat.com> Date: Fri Jun 4 15:59:38 2021 +0100 libstdc++: Fix value categories used by ranges access CPOs [PR 100824] The implementation of P2091R0 was incomplete, so that some range access CPOs used perfect forwarding where they should not. This fixes it by consistently operating on lvalues. Some additional changes that are not necessary to fix the bug: Modify the __as_const helper to simplify its usage. Instead of deducing the value category from its argument, and requiring callers to forward the argument as the correct category, add a non-deduced template parameter which is used for the value category and accept the argument as an lvalue. This means callers say __as_const<T>(t) instead of __as_const(std::forward<T>(t)). Always use an lvalue reference type as the template argument for the _S_noexcept helpers, so that we only instantiate one specialization for lvalues and rvalues of the same type. Move some helper concepts and functions from namespace std::__detail to ranges::__cust_access, to be consistent with the ranges::begin CPO. This ensures that the __adl_begin concept and the _Begin::operator() function are in the same namespace, so unqualified lookup is consistent and the poison pills for begin are visible to both. Simplified static assertions for arrays, because the expression a+0 is already ill-formed for an array of incomplete type. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: PR libstdc++/100824 * include/bits/iterator_concepts.h (__detail::__decay_copy) (__detail::__member_begin, __detail::__adl_begin): Move to namespace ranges::__cust_access. (__detail::__ranges_begin): Likewise, and rename to __begin. Remove redundant static assertion. * include/bits/ranges_base.h (_Begin, _End, _RBegin, _REnd): Use lvalue in noexcept specifier. (__as_const): Add non-deduced parameter for value category. (_CBegin, _CEnd, _CRBegin, _CREnd, _CData): Adjust uses of __as_const. (__member_size, __adl_size, __member_empty, __size0_empty): (__eq_iter_empty, __adl_data): Use lvalue objects in requirements. (__sentinel_size): Likewise. Add check for conversion to unsigned-like. (__member_data): Allow non-lvalue types to satisfy the concept, but use lvalue object in requirements. (_Size, _SSize): Remove forwarding to always use an lvalue. (_Data): Likewise. Add static assertion for arrays. * testsuite/std/ranges/access/cdata.cc: Adjust expected behaviour for rvalues. Add negative tests for ill-formed expressions. * testsuite/std/ranges/access/data.cc: Likewise. * testsuite/std/ranges/access/empty.cc: Adjust expected behaviour for rvalues. * testsuite/std/ranges/access/size.cc: Likewise.
next prev parent reply other threads:[~2021-06-04 14:59 UTC|newest] Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-05-29 11:17 [Bug libstdc++/100824] New: " hewillk at gmail dot com 2021-06-03 15:13 ` [Bug libstdc++/100824] " redi at gcc dot gnu.org 2021-06-04 11:39 ` redi at gcc dot gnu.org 2021-06-04 14:59 ` cvs-commit at gcc dot gnu.org [this message] 2021-06-04 16:52 ` hewillk at gmail dot com 2021-06-04 19:18 ` redi at gcc dot gnu.org 2021-06-04 20:42 ` cvs-commit at gcc dot gnu.org 2021-06-04 20:48 ` redi at gcc dot gnu.org 2021-06-05 3:16 ` hewillk at gmail dot com 2021-06-05 6:35 ` redi at gcc dot gnu.org 2021-06-05 10:45 ` cvs-commit at gcc dot gnu.org 2021-06-11 22:25 ` cvs-commit at gcc dot gnu.org 2021-06-11 22:25 ` cvs-commit at gcc dot gnu.org 2021-06-11 22:25 ` cvs-commit at gcc dot gnu.org 2022-09-07 12:32 ` redi at gcc dot gnu.org 2022-09-07 12:32 ` redi at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-100824-4-BT5wuTGwIE@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).