[Bug tree-optimization/104165] [12 Regression] -Warray-bounds for unreachable code inlined from std::sort()
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104165 --- Comment #13 from Xi Ruoyao --- For anyone attempting to claim this not fixed for 13 or later please see PR107986 first.
[Bug tree-optimization/104165] [12 Regression] -Warray-bounds for unreachable code inlined from std::sort()
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104165 Xi Ruoyao changed: What|Removed |Added CC||xry111 at gcc dot gnu.org --- Comment #12 from Xi Ruoyao --- (In reply to teodor_spaeren from comment #11) > This just hit me on gcc 14.1: > > https://godbolt.org/z/31G5dxz55 It's PR107986 and not this one. The underlying reason is different.
[Bug tree-optimization/104165] [12 Regression] -Warray-bounds for unreachable code inlined from std::sort()
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104165 teodor_spaeren at riseup dot net changed: What|Removed |Added CC||teodor_spaeren at riseup dot net --- Comment #11 from teodor_spaeren at riseup dot net --- This just hit me on gcc 14.1: https://godbolt.org/z/31G5dxz55
[Bug tree-optimization/104165] [12 Regression] -Warray-bounds for unreachable code inlined from std::sort()
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104165 --- Comment #10 from Fedor Chelnokov --- This issue happens in GCC 13.2 as well: https://godbolt.org/z/TfGx3YccG
[Bug tree-optimization/104165] [12 Regression] -Warray-bounds for unreachable code inlined from std::sort()
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104165 Richard Biener changed: What|Removed |Added Target Milestone|12.3|12.4 --- Comment #9 from Richard Biener --- GCC 12.3 is being released, retargeting bugs to GCC 12.4.
[Bug tree-optimization/104165] [12 Regression] -Warray-bounds for unreachable code inlined from std::sort()
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104165 --- Comment #8 from Richard Biener --- I have opened PR107986 for the testcase in comment#2 which isn't yet fixed on trunk.
[Bug tree-optimization/104165] [12 Regression] -Warray-bounds for unreachable code inlined from std::sort()
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104165 --- Comment #7 from CVS Commits --- The master branch has been updated by Richard Biener : https://gcc.gnu.org/g:790ff87f675f28bce5e7e35918ae09c3ece4ec4d commit r13-4499-g790ff87f675f28bce5e7e35918ae09c3ece4ec4d Author: Richard Biener Date: Tue Dec 6 08:22:01 2022 +0100 tree-optimization/104165 - bougs -Warray-bounds, add testcase The following adds the testcase from the description which was fixed by r13-2894-gbe4a6551ed37c1. PR tree-optimization/104165 * g++.dg/warn/Warray-bounds-pr104165-1.C: New testcase.
[Bug tree-optimization/104165] [12 Regression] -Warray-bounds for unreachable code inlined from std::sort()
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104165 Jakub Jelinek changed: What|Removed |Added Keywords|needs-bisection | CC||jakub at gcc dot gnu.org --- Comment #6 from Jakub Jelinek --- r13-2894-gbe4a6551ed37c1e7dbdfb9400fc2e2b5d40c5be2 made the warning go away.
[Bug tree-optimization/104165] [12 Regression] -Warray-bounds for unreachable code inlined from std::sort()
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104165 Richard Biener changed: What|Removed |Added CC||rguenth at gcc dot gnu.org Known to work||13.0 Keywords||needs-bisection Summary|[12/13 Regression] |[12 Regression] |-Warray-bounds for |-Warray-bounds for |unreachable code inlined|unreachable code inlined |from std::sort()|from std::sort() --- Comment #5 from Richard Biener --- This seems to be fixed on trunk - can somebody bisect what did so?
[Bug tree-optimization/104165] [12 Regression] -Warray-bounds for unreachable code inlined from std::sort()
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104165 Martin Sebor changed: What|Removed |Added URL||https://bugzilla.redhat.com ||/show_bug.cgi?id=2051783 Keywords||missed-optimization --- Comment #2 from Martin Sebor --- See also another similar test case reduced in https://bugzilla.redhat.com/show_bug.cgi?id=2051783: #include 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): [local count: 71766220]: std::__insertion_sort.isra (, [(void *) + 64B]); <<< -Warray-bounds goto ; [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.
[Bug tree-optimization/104165] [12 Regression] -Warray-bounds for unreachable code inlined from std::sort()
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104165 Martin Sebor changed: What|Removed |Added Status|UNCONFIRMED |NEW CC||msebor at gcc dot gnu.org Last reconfirmed||2022-01-21 Blocks||56456 Summary|[12 Regression] Incorrectly |[12 Regression] |identifying array bounds|-Warray-bounds for |with -O2|unreachable code inlined |-Werror=array-bounds|from std::sort() Ever confirmed|0 |1 --- Comment #1 from Martin Sebor --- The warning triggers for the out of bounds pointer addition in + 64 for an array of 16 chars: int foo (int n) { unsigned char f.148[16]; ... [local count: 116203857]: _25 = ASSERT_EXPR <_15, _15 != >; _6 = (signed long) _14; _19 = _6 /[ex] 4; __n.3_20 = (long unsigned int) _19; _21 = __builtin_clzl (__n.3_20); _22 = 63 - _21; _23 = (long int) _22; _24 = _23 * 2; std::__introsort_loop > > (, _25, _24, __comp); if (_14 > 64) goto ; [50.00%] else goto ; [50.00%] [local count: 58101929]: std::__insertion_sort.constprop (, [(void *) + 64B]); <<< -Warray-bounds goto ; [100.00%] The basic block is removed later, in CCP3, as unreachable: Removing basic block 8 ;; basic block 8, loop depth 0 ;; pred: std::__insertion_sort.constprop (, [(void *) + 64B]); if ( [(void *) + 64B] != _15) goto ; [89.00%] else goto ; [11.00%] ;; succ: 9 ;; 13 The warning runs too early to benefit from the subsequent simplification. This is one instance of a false positive that something like __builtin_warning() would cure. GCC 11 emits (and eliminates) the same invalid expression but the warning is suppressed because in GCC 11 -Warray-bounds wasn't issued code inlined from system headers. That's a GCC 12 change. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56456 [Bug 56456] [meta-bug] bogus/missing -Warray-bounds