On 3/18/19 1:03 PM, Martin Sebor wrote: > I the -Warray-bounds enhancement committed at the beginning > of the GCC 9 window I tried to correctly handle offsets in > MEM_REFs in the [max, min] kind of a range after converting > from sizetype to ptrdiff_type, but I did it wrong. The bug > results in false positives in some unusual use cases that > I didn't consider at the time. > > The attached patch removes this incorrect handling and uses > the conservative anti-range handling for these cases instead. > > Martin > > PS Is there some technical reason why pointer offsets are > represented as the unsigned sizetype when they can be signed? I'm not aware of a conscious decision to treat them as unsigned or a particular target need to do so. It's most likely a historical accident.
> > gcc-89720.diff > > PR tree-optimization/89720 - Spurious -Warray-bounds warning on a range with > max < min > > gcc/ChangeLog: > > PR tree-optimization/89720 > * tree-vrp.c (vrp_prop::check_mem_ref): Treat range with max < min > more conservatively, the same as anti-range. > > gcc/testsuite/ChangeLog: > > PR tree-optimization/89720 > * gcc.dg/Warray-bounds-42.c: New test. OK jeff