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 c++/106276] Missing -Wpessimizing-move warning Date: Mon, 15 Aug 2022 14:00:32 +0000 [thread overview] Message-ID: <bug-106276-4-AeLQyHBkFL@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-106276-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106276 --- Comment #6 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:ae3459cd5956fcd29e8aa5408efb707cb7d9b14f commit r13-2045-gae3459cd5956fcd29e8aa5408efb707cb7d9b14f Author: Marek Polacek <polacek@redhat.com> Date: Fri Jul 22 18:10:30 2022 -0400 c++: Extend -Wpessimizing-move for class prvalues [PR106276] We already have a warning that warns about pessimizing std::move in a return statement, when it prevents the NRVO: T fn() { T t; return std::move (t); // warning \o/ } However, the warning doesn't warn when what we are returning is a class prvalue, that is, when std::move prevents the RVO: T fn() { T t; return std::move (T{}); // no warning :-( } This came up recently in GCC: <https://gcc.gnu.org/pipermail/gcc-patches/2022-July/598177.html>. This patch fixes that. I would like to extend the warning further, so that it warns in more contexts, e.g.: T t = std::move(T()); or void foo (T); foo (std::move(T())); PR c++/106276 gcc/cp/ChangeLog: * typeck.cc (can_do_rvo_p): New. (maybe_warn_pessimizing_move): Warn when moving a temporary object in a return statement prevents copy elision. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/Wpessimizing-move7.C: New test.
next prev parent reply other threads:[~2022-08-15 14:00 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-07-13 0:51 [Bug c++/106276] New: " mpolacek at gcc dot gnu.org 2022-07-13 7:21 ` [Bug c++/106276] " marxin at gcc dot gnu.org 2022-07-13 11:58 ` mpolacek at gcc dot gnu.org 2022-07-13 18:36 ` dcb314 at hotmail dot com 2022-07-13 19:09 ` mpolacek at gcc dot gnu.org 2022-07-13 20:16 ` redi at gcc dot gnu.org 2022-07-13 20:19 ` redi at gcc dot gnu.org 2022-07-16 0:43 ` mpolacek at gcc dot gnu.org 2022-08-15 14:00 ` cvs-commit at gcc dot gnu.org [this message] 2022-08-15 14:04 ` mpolacek 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-106276-4-AeLQyHBkFL@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).