public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/101165] New: [C++23] P2266R1 - Simpler implicit move @ 2021-06-22 17:06 mpolacek at gcc dot gnu.org 2021-06-22 17:08 ` [Bug c++/101165] " mpolacek at gcc dot gnu.org ` (5 more replies) 0 siblings, 6 replies; 7+ messages in thread From: mpolacek at gcc dot gnu.org @ 2021-06-22 17:06 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101165 Bug ID: 101165 Summary: [C++23] P2266R1 - Simpler implicit move Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: mpolacek at gcc dot gnu.org Blocks: 98940 Target Milestone: --- See <wg21.link/p2266>. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98940 [Bug 98940] Implement C++23 language features ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/101165] [C++23] P2266R1 - Simpler implicit move 2021-06-22 17:06 [Bug c++/101165] New: [C++23] P2266R1 - Simpler implicit move mpolacek at gcc dot gnu.org @ 2021-06-22 17:08 ` mpolacek at gcc dot gnu.org 2022-08-16 12:56 ` mpolacek at gcc dot gnu.org ` (4 subsequent siblings) 5 siblings, 0 replies; 7+ messages in thread From: mpolacek at gcc dot gnu.org @ 2021-06-22 17:08 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101165 Marek Polacek <mpolacek at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2021-06-22 Ever confirmed|0 |1 --- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> --- Clickable link: https://wg21.link/p2266 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/101165] [C++23] P2266R1 - Simpler implicit move 2021-06-22 17:06 [Bug c++/101165] New: [C++23] P2266R1 - Simpler implicit move mpolacek at gcc dot gnu.org 2021-06-22 17:08 ` [Bug c++/101165] " mpolacek at gcc dot gnu.org @ 2022-08-16 12:56 ` mpolacek at gcc dot gnu.org 2022-09-27 23:36 ` cvs-commit at gcc dot gnu.org ` (3 subsequent siblings) 5 siblings, 0 replies; 7+ messages in thread From: mpolacek at gcc dot gnu.org @ 2022-08-16 12:56 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101165 Marek Polacek <mpolacek at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|unassigned at gcc dot gnu.org |mpolacek at gcc dot gnu.org Status|NEW |ASSIGNED --- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> --- This proposal has been approved by CWG. I'll adjust our cxx-status. ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/101165] [C++23] P2266R1 - Simpler implicit move 2021-06-22 17:06 [Bug c++/101165] New: [C++23] P2266R1 - Simpler implicit move mpolacek at gcc dot gnu.org 2021-06-22 17:08 ` [Bug c++/101165] " mpolacek at gcc dot gnu.org 2022-08-16 12:56 ` mpolacek at gcc dot gnu.org @ 2022-09-27 23:36 ` cvs-commit at gcc dot gnu.org 2022-09-27 23:39 ` mpolacek at gcc dot gnu.org ` (2 subsequent siblings) 5 siblings, 0 replies; 7+ messages in thread From: cvs-commit at gcc dot gnu.org @ 2022-09-27 23:36 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101165 --- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>: https://gcc.gnu.org/g:772d532e0ba1e4b22c2b7d576e14b34ee929c093 commit r13-2905-g772d532e0ba1e4b22c2b7d576e14b34ee929c093 Author: Marek Polacek <polacek@redhat.com> Date: Wed Aug 31 17:37:59 2022 -0400 c++: Implement C++23 P2266R1, Simpler implicit move [PR101165] This patch implements https://wg21.link/p2266, which, once again, changes the implicit move rules. Here's a brief summary of various changes in this area: r125211: Introduced moving from certain lvalues when returning them r171071: CWG 1148, enable move from value parameter on return r212099: CWG 1579, it's OK to call a converting ctor taking an rvalue r251035: CWG 1579, do maybe-rvalue overload resolution twice r11-2411: Avoid calling const copy ctor on implicit move r11-2412: C++20 implicit move changes, remove the fallback overload resolution, allow move on throw of parameters and implicit move of rvalue references P2266 enables the implicit move even for functions that return references. That is, we will now perform a move in X&& foo (X&& x) { return x; } P2266 also removes the fallback overload resolution, but this was resolved by r11-2412: we only do convert_for_initialization with LOOKUP_PREFER_RVALUE in C++17 and older. P2266 also says that a returned move-eligible id-expression is always an xvalue. This required some further short, but nontrivial changes, especially when it comes to deduction, because we have to pay attention to whether we have auto, auto&& (which is like T&&), or decltype(auto) with (un)parenthesized argument. In C++23, decltype(auto) f(int&& x) { return (x); } auto&& f(int x) { return x; } both should deduce to 'int&&' but decltype(auto) f(int x) { return x; } should deduce to 'int'. A cornucopia of tests attached. I've also verified that we behave like clang++. xvalue_p seemed to be broken: since the introduction of clk_implicit_rval, it cannot use '==' when checking for clk_rvalueref. Since this change breaks code, it's only enabled in C++23. In particular, this code will not compile in C++23: int& g(int&& x) { return x; } because x is now treated as an rvalue, and you can't bind a non-const lvalue reference to an rvalue. This patch also fixes PR106882 (the check_return_expr changes). PR c++/101165 PR c++/106882 gcc/c-family/ChangeLog: * c-cppbuiltin.cc (c_cpp_builtins): Define __cpp_implicit_move. gcc/cp/ChangeLog: * call.cc (reference_binding): Check clk_implicit_rval in C++20 only. * cp-tree.h (unparenthesized_id_or_class_member_access_p): Declare. * pt.cc (unparenthesized_id_or_class_member_access_p): New function, broken out of... (do_auto_deduction): ...here. Use it. In C++23, maybe call treat_lvalue_as_rvalue_p. * tree.cc (xvalue_p): Check & clk_rvalueref, not == clk_rvalueref. * typeck.cc (check_return_expr): Allow implicit move for functions returning a reference as well, or when the return value type is not a scalar type. gcc/testsuite/ChangeLog: * g++.dg/conversion/pr41426.C: Add dg-error for C++23. * g++.dg/cpp0x/elision_weak.C: Likewise. * g++.dg/cpp0x/move-return3.C: Only link in c++20_down. * g++.dg/cpp1y/decltype-auto2.C: Add dg-error for C++23. * g++.dg/cpp1y/lambda-generic-89419.C: Likewise. * g++.dg/cpp23/feat-cxx2b.C: Test __cpp_implicit_move. * g++.dg/gomp/pr56217.C: Only compile in c++20_down. * g++.dg/warn/Wno-return-local-addr.C: Add dg-error for C++23. * g++.dg/warn/Wreturn-local-addr.C: Adjust dg-error. * g++.old-deja/g++.brendan/crash55.C: Add dg-error for C++23. * g++.old-deja/g++.jason/temporary2.C: Likewise. * g++.old-deja/g++.mike/p2846b.C: Adjust. * g++.dg/cpp1y/decltype-auto6.C: New test. * g++.dg/cpp23/decltype1.C: New test. * g++.dg/cpp23/decltype2.C: New test. * g++.dg/cpp23/elision1.C: New test. * g++.dg/cpp23/elision2.C: New test. * g++.dg/cpp23/elision3.C: New test. * g++.dg/cpp23/elision4.C: New test. * g++.dg/cpp23/elision5.C: New test. * g++.dg/cpp23/elision6.C: New test. * g++.dg/cpp23/elision7.C: New test. ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/101165] [C++23] P2266R1 - Simpler implicit move 2021-06-22 17:06 [Bug c++/101165] New: [C++23] P2266R1 - Simpler implicit move mpolacek at gcc dot gnu.org ` (2 preceding siblings ...) 2022-09-27 23:36 ` cvs-commit at gcc dot gnu.org @ 2022-09-27 23:39 ` mpolacek at gcc dot gnu.org 2022-09-27 23:40 ` mpolacek at gcc dot gnu.org 2024-02-06 17:58 ` pinskia at gcc dot gnu.org 5 siblings, 0 replies; 7+ messages in thread From: mpolacek at gcc dot gnu.org @ 2022-09-27 23:39 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101165 Bug 101165 depends on bug 106882, which changed state. Bug 106882 Summary: passing X as 'this' argument discards qualifiers https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106882 What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |RESOLVED Resolution|--- |FIXED ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/101165] [C++23] P2266R1 - Simpler implicit move 2021-06-22 17:06 [Bug c++/101165] New: [C++23] P2266R1 - Simpler implicit move mpolacek at gcc dot gnu.org ` (3 preceding siblings ...) 2022-09-27 23:39 ` mpolacek at gcc dot gnu.org @ 2022-09-27 23:40 ` mpolacek at gcc dot gnu.org 2024-02-06 17:58 ` pinskia at gcc dot gnu.org 5 siblings, 0 replies; 7+ messages in thread From: mpolacek at gcc dot gnu.org @ 2022-09-27 23:40 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101165 Marek Polacek <mpolacek at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |RESOLVED Resolution|--- |FIXED --- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> --- Implemented in GCC 13. ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/101165] [C++23] P2266R1 - Simpler implicit move 2021-06-22 17:06 [Bug c++/101165] New: [C++23] P2266R1 - Simpler implicit move mpolacek at gcc dot gnu.org ` (4 preceding siblings ...) 2022-09-27 23:40 ` mpolacek at gcc dot gnu.org @ 2024-02-06 17:58 ` pinskia at gcc dot gnu.org 5 siblings, 0 replies; 7+ messages in thread From: pinskia at gcc dot gnu.org @ 2024-02-06 17:58 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101165 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|--- |13.0 ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-02-06 17:58 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-06-22 17:06 [Bug c++/101165] New: [C++23] P2266R1 - Simpler implicit move mpolacek at gcc dot gnu.org 2021-06-22 17:08 ` [Bug c++/101165] " mpolacek at gcc dot gnu.org 2022-08-16 12:56 ` mpolacek at gcc dot gnu.org 2022-09-27 23:36 ` cvs-commit at gcc dot gnu.org 2022-09-27 23:39 ` mpolacek at gcc dot gnu.org 2022-09-27 23:40 ` mpolacek at gcc dot gnu.org 2024-02-06 17:58 ` pinskia at gcc dot gnu.org
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).