[Bug tree-optimization/122197] [16/17 Regression] predictively devirtualization vs middle-end warnings since r16-4000

"alexey.klimkin at intel dot com via Gcc-bugs" <[email protected]> Wed, 05 Aug 2026 20:56:15 +0000
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122197

--- Comment #25 from Alexey Klimkin <alexey.klimkin at intel dot com> ---
Created attachment 65250
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=65250&action=edit
Proposed patch: ignore end-of-object clobbers in array-bounds checking

I attached a proposed patch for PR122197. The warning is emitted for an
end-of-object clobber left by speculative devirtualization. Such a clobber does
not access memory or generate code, and its optimizer-introduced type does not
describe an actual out-of-bounds access.

The patch skips only CLOBBER_OBJECT_END statements in the array-bounds walker;
beginning-of-object clobbers remain checked. It includes a reduced regression
test, and g++.dg/warn/Warray-bounds-20.C continues to cover the retained
diagnostic. It was bootstrapped and regression-tested on x86_64-pc-linux-gnu
with no lost PASSes or new failures in check-gcc or check-g++. The patch is
submitted under the DCO sign-off included in the attachment.