public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "msebor at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/104165] [12 Regression] -Warray-bounds for unreachable code inlined from std::sort() Date: Tue, 08 Feb 2022 21:07:07 +0000 [thread overview] Message-ID: <bug-104165-4-ehvEPG7nkr@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-104165-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104165 Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- URL| |https://bugzilla.redhat.com | |/show_bug.cgi?id=2051783 Keywords| |missed-optimization --- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> --- See also another similar test case reduced in https://bugzilla.redhat.com/show_bug.cgi?id=2051783: #include <algorithm> bool cond; int foo; int func (void) { int a[3], qa = 0; for(int i = 0; i < 3; i++) if (cond) a[qa++] = foo; std::sort (a, a + qa); return 0; } The warning is issued for the synthesized call to std::__insertion_sort.isra() in basic block 9 (vrp1 output): <bb 9> [local count: 71766220]: std::__insertion_sort.isra (&a, &MEM <int[3]> [(void *)&a + 64B]); <<< -Warray-bounds goto <bb 14>; [100.00%] The block is unreachable but GCC is unable to determine that from the loop. Adding an annotation just after the loop asserting that avoids the warning and also improves the emitted object code. The same warning triggers in GCC 11 with -Wsystem-headers. The difference in GCC 12 is that -Wsystem-headers no longer disables warnings for code defined in system headers that's inlined into user code.
next prev parent reply other threads:[~2022-02-08 21:07 UTC|newest] Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-01-21 15:40 [Bug c++/104165] New: Incorrectly identifying array bounds with -O2 -Werror=array-bounds kbrabml at gmail dot com 2022-01-21 17:04 ` [Bug tree-optimization/104165] [12 Regression] " pinskia at gcc dot gnu.org 2022-01-21 17:16 ` [Bug tree-optimization/104165] [12 Regression] -Warray-bounds for unreachable code inlined from std::sort() msebor at gcc dot gnu.org 2022-02-08 21:07 ` msebor at gcc dot gnu.org [this message] 2022-05-06 8:32 ` [Bug tree-optimization/104165] [12/13 " jakub at gcc dot gnu.org 2022-07-26 13:03 ` rguenth at gcc dot gnu.org 2022-12-05 15:39 ` [Bug tree-optimization/104165] [12 " rguenth at gcc dot gnu.org 2022-12-05 16:05 ` jakub at gcc dot gnu.org 2022-12-06 7:24 ` cvs-commit at gcc dot gnu.org 2022-12-06 7:29 ` rguenth at gcc dot gnu.org 2023-05-08 12:23 ` rguenth at gcc dot gnu.org 2023-09-27 12:36 ` fchelnokov at gmail dot com 2024-06-03 17:36 ` teodor_spaeren at riseup dot net 2024-06-03 18:09 ` xry111 at gcc dot gnu.org 2024-06-03 18:10 ` xry111 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-104165-4-ehvEPG7nkr@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).