]> git.ipfire.org Git - people/ms/gcc.git/commit
tree-optimization/106904 - bogus -Wstringopt-overflow with vectors
authorRichard Biener <rguenther@suse.de>
Wed, 7 Dec 2022 13:42:24 +0000 (14:42 +0100)
committerRichard Biener <rguenther@suse.de>
Wed, 15 Mar 2023 09:04:00 +0000 (10:04 +0100)
commit97d599e09b0fd389a7cbac8867e56977ec97900f
tree9795ad12387f665024c8d2a3c9f65deb5bec33e7
parentcadfee66f2e3c8b65533c51fbf8dbcab08c89d52
tree-optimization/106904 - bogus -Wstringopt-overflow with vectors

The following avoids CSE of &ps->wp to &ps->wp.hwnd confusing
-Wstringopt-overflow by making sure to produce addresses to the
biggest container from vectorization.  For this I introduce
strip_zero_offset_components which turns &ps->wp.hwnd into
&(*ps) and use that to base the vector data references on.
That will also work for addresses with variable components,
alternatively emitting pointer arithmetic via calling
get_inner_reference and gimplifying that would be possible
but likely more intrusive.

This is by no means a complete fix for all of those issues
(avoiding ADDR_EXPRs in favor of pointer arithmetic might be).
Other passes will have similar issues.

In theory that might now cause false negatives.

PR tree-optimization/106904
* tree.h (strip_zero_offset_components): Declare.
* tree.cc (strip_zero_offset_components): Define.
* tree-vect-data-refs.cc (vect_create_addr_base_for_vector_ref):
Strip zero offset components before building the address.

* gcc.dg/Wstringop-overflow-pr106904.c: New testcase.

(cherry picked from commit f8d136e50e6f82cba793483d910a2b2643108508)
gcc/testsuite/gcc.dg/Wstringop-overflow-pr106904.c [new file with mode: 0644]
gcc/tree-vect-data-refs.cc
gcc/tree.cc
gcc/tree.h