]> git.ipfire.org Git - thirdparty/gcc.git/commit
tree-optimization/117424 - invalid LIM of trapping ref
authorRichard Biener <rguenther@suse.de>
Tue, 28 Jan 2025 11:28:14 +0000 (12:28 +0100)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 28 Jan 2025 13:20:06 +0000 (14:20 +0100)
commitf1e776ce58ae4a6ae67886adb4ae806598e2c7ef
treeaa66e7e730f3239b2603acdad95c5a7d2ff6e09b
parentd6e66e7b3a40315ad303344e19bccb4006c51cac
tree-optimization/117424 - invalid LIM of trapping ref

The following addresses a bug in tree_could_trap_p leading to
hoisting of a possibly trapping, because of out-of-bound, access.
We only ensured the first accessed byte is within a decl there,
the patch makes sure the whole base of the reference is within it.
This is pessimistic if a handled component would then subset to
a sub-object within the decl but upcasting of a decl to larger
types should be uncommon, questionable, and wrong without
-fno-strict-aliasing.

The testcase is a bit fragile, but I could not devise a (portable)
way to ensure an out-of-bound access to a decl would fault.

PR tree-optimization/117424
* tree-eh.cc (tree_could_trap_p): Verify the base is
fully contained within a decl.

* gcc.dg/tree-ssa/ssa-lim-25.c: New testcase.
gcc/testsuite/gcc.dg/tree-ssa/ssa-lim-25.c [new file with mode: 0644]
gcc/tree-eh.cc