[PATCH] avoid -Warray-bounds checks for vtable assignments (PR 98266)

Jeff Law law@redhat.com
Mon Feb 8 19:59:37 GMT 2021



On 1/19/21 5:56 PM, Martin Sebor via Gcc-patches wrote:
> Similar to the problem reported for -Wstringop-overflow in pr98266
> and already fixed, -Warray-bounds is also susceptible to false
> positives in assignments and copies involving virtual inheritance.
> Because the two warnings don't share code yet (hopefully in GCC 12)
> the attached patch adds its own workaround for this problem to
> gimple-array-bounds.cc, this one slightly more crude because of
> the limited insight the array bounds checking has into the checked
> expressions.
>
> Tested on x86_64-linux.
>
> Martin
>
> gcc-98266.diff
>
> PR middle-end/98266 - bogus array subscript is partly outside array bounds on virtual inheritance
>
> gcc/ChangeLog:
>
> 	PR middle-end/98266
> 	* gimple-array-bounds.cc (array_bounds_checker::check_array_bounds):
> 	Avoid checking references involving artificial members.
>
> gcc/testsuite/ChangeLog:
>
> 	PR middle-end/98266
> 	* g++.dg/warn/Warray-bounds-15.C: New test.
It seems to me that we've got the full statement at some point  and thus
the full expression so at some point couldn't we detect when
TYPE_SIZE_UNIT!= DECL_SIZE_UNIT?  Or should we be using TYPE_SIZE_UNIT
rather than DECL_SIZE_UNIT in gimple-array-bounds.cc

Am I missing something?


jeff



More information about the Gcc-patches mailing list