[PATCH] Use enclosing object size if it's smaller than member [PR 101475]
Jason Merrill
jason@redhat.com
Tue Jan 11 21:43:30 GMT 2022
On 12/16/21 14:56, Martin Sebor via Gcc-patches wrote:
> Enabling vectorization at -O2 caused quite a few tests for
> warnings to start failing in GCC 12. These tests were xfailed
> and bugs were opened to track the problems until they can be
> fully analyzed and ultimately fixed before GCC 12 is released.
>
> I've now started going through these and the first such bug
> I tackled is PR 102944. As it turns out, the xfails there
> are all due to a known limitation tracked in PR 101475: when
> determining the size of a destination for A COMPONENT_REF,
> unless asked for the size of the complete object,
> compute_objsize() only considers the size of the referenced
> member, even when the member is larger than the object would
> allow. This prevents warnings from diagnosing unvectorized
> past-the-end accesses to objects in backing buffers (such as
> in character arrays or allocated chunks of memory).
>
> Many (though not all) accesses that are vectorized are diagnosed
> because there the COMPONENT_REF is replaced by a MEM_REF. But
> because vectorization depends on target-specific things like
> alignment requirements, what is and isn't diagnosed also tends
> to be target-specific, making these tests quite brittle..
>
> The attached patch corrects this oversight by using the complete
> object's size instead of the member when the former is smaller.
> Besides improving the out-of-bounds access detection it also
> makes the tests behave more consistently across targets.
>
> Tested on x86_64-linux and by building Glibc and verifying
> that the change triggers no new warnings.
> + /* Unconditionally determine the size of the base object (it could
> + be smaller than the referenced member). */
This comment could use a mention of the backing buffer case. OK with
that change.
Jason
More information about the Gcc-patches
mailing list