diff options
author | Richard Sandiford <richard.sandiford@arm.com> | 2019-04-18 12:29:56 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2019-04-18 12:29:56 +0000 |
commit | cd7f7c54a43c435152b2ac76b6e74ae6a3430472 (patch) | |
tree | d7ec130591e850d27f196e742e40bfba9f1d7602 /gcc/rtlanal.c | |
parent | e62817edaecb4c8cb5a4f3c608f0ea52276449a1 (diff) | |
download | gcc-cd7f7c54a43c435152b2ac76b6e74ae6a3430472.zip gcc-cd7f7c54a43c435152b2ac76b6e74ae6a3430472.tar.gz gcc-cd7f7c54a43c435152b2ac76b6e74ae6a3430472.tar.bz2 |
Fix two ubsan failures (PR85164)
Two fixes for UB when handling very large offsets. The calculation in
force_int_to_mode would have been correct if signed integers used modulo
arithmetic, so just switch to unsigned types. The calculation in
rtx_addr_can_trap_p_1 didn't handle overflow properly, so switch to
known_subrange_p instead (which is supposed to handle all cases).
2019-04-18 Richard Sandiford <richard.sandiford@arm.com>
gcc/
PR middle-end/85164
* combine.c (force_int_to_mode): Cast the argument rather than
the result of known_alignment.
* rtlanal.c (rtx_addr_can_trap_p_1): Use known_subrange_p.
gcc/testsuite/
PR middle-end/85164
* gcc.dg/pr85164-1.c, gcc.dg/pr85164-2.c: New tests.
From-SVN: r270442
Diffstat (limited to 'gcc/rtlanal.c')
-rw-r--r-- | gcc/rtlanal.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/rtlanal.c b/gcc/rtlanal.c index 3873b40..268a387 100644 --- a/gcc/rtlanal.c +++ b/gcc/rtlanal.c @@ -521,7 +521,7 @@ rtx_addr_can_trap_p_1 (const_rtx x, poly_int64 offset, poly_int64 size, return (!known_size_p (decl_size) || known_eq (decl_size, 0) ? maybe_ne (offset, 0) - : maybe_gt (offset + size, decl_size)); + : !known_subrange_p (offset, size, 0, decl_size)); } return 0; |