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++/94695] Implement -Wrange-loop-analysis Date: Sat, 21 Nov 2020 21:28:51 +0000 [thread overview] Message-ID: <bug-94695-4-RFibGEJeTu@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-94695-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94695 --- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>: https://gcc.gnu.org/g:c51e31a06f2c740c55852a683aa7ffdc20417362 commit r11-5234-gc51e31a06f2c740c55852a683aa7ffdc20417362 Author: Marek Polacek <polacek@redhat.com> Date: Mon Nov 9 21:15:33 2020 -0500 c++: Extend -Wrange-loop-construct for binding-to-temp [PR94695] This patch finishes the second half of -Wrange-loop-construct I promised to implement: it warns when a loop variable in a range-based for-loop is initialized with a value of a different type resulting in a copy. For instance: int arr[10]; for (const double &x : arr) { ... } where in every iteration we have to create and destroy a temporary value of type double, to which we bind the reference. This could negatively impact performance. As per Clang, this doesn't warn when the range returns a copy, hence the glvalue_p check. gcc/ChangeLog: PR c++/94695 * doc/invoke.texi: Update the -Wrange-loop-construct description. gcc/cp/ChangeLog: PR c++/94695 * parser.c (warn_for_range_copy): Warn when the loop variable is initialized with a value of a different type resulting in a copy. gcc/testsuite/ChangeLog: PR c++/94695 * g++.dg/warn/Wrange-loop-construct2.C: New test.
next prev parent reply other threads:[~2020-11-21 21:28 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-04-21 14:37 [Bug c++/94695] New: " mpolacek at gcc dot gnu.org 2020-04-21 14:37 ` [Bug c++/94695] " mpolacek at gcc dot gnu.org 2020-09-22 16:28 ` mpolacek at gcc dot gnu.org 2020-09-29 23:03 ` cvs-commit at gcc dot gnu.org 2020-09-29 23:05 ` mpolacek at gcc dot gnu.org 2020-11-21 21:28 ` cvs-commit at gcc dot gnu.org [this message] 2020-11-21 21:30 ` mpolacek at gcc dot gnu.org 2021-05-10 10:03 ` 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-94695-4-RFibGEJeTu@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).