]> 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, 24 Jun 2025 11:07:50 +0000 (13:07 +0200)
commiteafe890ea3904c109b6bce663a81a91d61356cb4
tree8076a4ecc0d5c4a0560faabd91bc63d61bf097f3
parentf4dbdeabb2944d014d506a537a576a6f9a1f4c1f
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.

(cherry picked from commit f1e776ce58ae4a6ae67886adb4ae806598e2c7ef)
gcc/testsuite/gcc.dg/tree-ssa/ssa-lim-25.c [new file with mode: 0644]
gcc/tree-eh.cc