On Fri, 2020-05-08 at 15:46 -0600, Martin Sebor via Gcc-patches wrote:
> The improved detection of accesses to interior zero-length arrays
> fails to consider the case when the array is a member of a union.
> Such accesses are documented as supported so warning for them is
> not expected.  The attached patch adjusts the component_ref_size
> function to return the size of the enclosing union instead of
> the member array.
> 
> The VRP bit of the patch remove a couple of redundant tests and
> unreachable blocks from the check_mem_ref function.  The change
> is not directly related to the fix except that I noticed them
> while working on it and it seems safe either to include in this
> patch or commit on its own.
> 
> Tested on x86_64-linux.
> 
> PR middle-end/94940 - spurious -Warray-bounds for a zero length array member 
> of
> union
> 
> gcc/testsuite/ChangeLog:
> 
>       PR middle-end/94940
>       * gcc.dg/Warray-bounds-61.c: New test.
> 
> gcc/ChangeLog:
> 
>       PR middle-end/94940
>       * tree-vrp.c (vrp_prop::check_mem_ref): Remove unreachable code.
>       * tree.c (component_ref_size): Correct the handling or array members
>       of unions.
>       Drop a pointless test.
>       Rename a local variable.
OK
jeff

Reply via email to