https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105726
--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-12 branch has been updated by Richard Biener <rgue...@gcc.gnu.org>: https://gcc.gnu.org/g:9bc27ee76d510360637c9578ffdefeab5c336e86 commit r12-8452-g9bc27ee76d510360637c9578ffdefeab5c336e86 Author: Richard Biener <rguent...@suse.de> Date: Wed May 25 11:49:03 2022 +0200 tree-optimization/105726 - adjust array bound heuristic There's heuristic to detect ptr[1].a[...] out of bound accesses reasoning that if ptr points to an array of aggregates a trailing incomplete array has to have size zero. The following more thoroughly constrains the cases this applies to avoid false positive diagnostics. 2022-05-25 Richard Biener <rguent...@suse.de> PR tree-optimization/105726 * gimple-ssa-warn-restrict.cc (builtin_memref::set_base_and_offset): Constrain array-of-flexarray case more. * g++.dg/warn/Warray-bounds-27.C: New testcase. (cherry picked from commit e7c482b08076bb299742883c4ffd65b31e33200c)