On Fri, Jan 14, 2022 at 09:01:09AM +0530, Siddhesh Poyarekar wrote: > Restrict negative offset computation only to dynamic object sizes, where > size expressions are accurate and not a maximum/minimum estimate and in > cases where negative offsets definitely mean an underflow, e.g. in > MEM_REF of the whole object with negative ofset in addr_object_size. > > This ends up missing some cases where __builtin_object_size could have > come up with more precise results, so tests have been adjusted to > reflect that. > > gcc/ChangeLog: > > PR tree-optimization/104009 > * tree-object-size.c (compute_builtin_object_size): Bail out on > negative offset. > (plus_stmt_object_size): Return maximum of wholesize and minimum > of 0 for negative offset. > > gcc/testsuite/ChangeLog: > > PR tree-optimization/104009 > * gcc.dg/builtin-object-size-1.c (test10): New test. > * gcc.dg/builtin-object-size-3.c (test10): Likewise. > (test9): Expect zero size for negative offsets. > * gcc.dg/builtin-object-size-4.c (test8): Likewise. > * gcc.dg/builtin-object-size-5.c (test7): Drop test for > __builtin_object_size.
Ok. Jakub