]> git.ipfire.org Git - thirdparty/gcc.git/commit
Fix two ubsan failures (PR85164)
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 18 Apr 2019 12:29:56 +0000 (12:29 +0000)
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 18 Apr 2019 12:29:56 +0000 (12:29 +0000)
commitece3beac40ee149d606f968bd7eee1a62f279d56
treed7ec130591e850d27f196e742e40bfba9f1d7602
parenta894735cb9d21cf13cb5fe44dc1fd3bb1f2fa00d
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@270442 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/ChangeLog
gcc/combine.c
gcc/rtlanal.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr85164-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pr85164-2.c [new file with mode: 0644]