From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1734) id 5B8C6382C14F; Wed, 13 Jul 2022 18:23:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5B8C6382C14F MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Marek Polacek To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-1689] libcpp: Avoid pessimizing std::move [PR106272] X-Act-Checkin: gcc X-Git-Author: Marek Polacek X-Git-Refname: refs/heads/trunk X-Git-Oldrev: f70c18524221dcefa6cd26cee7b55503181bd912 X-Git-Newrev: 86a15b266a7284f3aa1b12494a475f31416b981d Message-Id: <20220713182353.5B8C6382C14F@sourceware.org> Date: Wed, 13 Jul 2022 18:23:53 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jul 2022 18:23:53 -0000 https://gcc.gnu.org/g:86a15b266a7284f3aa1b12494a475f31416b981d commit r13-1689-g86a15b266a7284f3aa1b12494a475f31416b981d Author: Marek Polacek Date: Tue Jul 12 20:18:56 2022 -0400 libcpp: Avoid pessimizing std::move [PR106272] std::move in a return statement can prevent the NRVO: PR106272 reports that we have two such cases in class label_text's member functions. We have -Wpessimizing-move that's supposed to detect problematic std::move uses, but in this case it didn't trigger. I've filed PR106276 to track that. PR preprocessor/106272 libcpp/ChangeLog: * include/line-map.h (class label_text): Don't std::move in a return statement. Diff: --- libcpp/include/line-map.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libcpp/include/line-map.h b/libcpp/include/line-map.h index c6379ce25b8..c434a246b13 100644 --- a/libcpp/include/line-map.h +++ b/libcpp/include/line-map.h @@ -1873,13 +1873,13 @@ public: longer-lived owner. */ static label_text borrow (const char *buffer) { - return std::move (label_text (const_cast (buffer), false)); + return label_text (const_cast (buffer), false); } /* Create a label_text instance that takes ownership of BUFFER. */ static label_text take (char *buffer) { - return std::move (label_text (buffer, true)); + return label_text (buffer, true); } /* Take ownership of the buffer, copying if necessary. */