https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85164
--- Comment #9 from rsandifo at gcc dot gnu.org <rsandifo at gcc dot gnu.org> --- Author: rsandifo Date: Thu Apr 18 12:29:56 2019 New Revision: 270442 URL: https://gcc.gnu.org/viewcvs?rev=270442&root=gcc&view=rev Log: 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.sandif...@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. Added: trunk/gcc/testsuite/gcc.dg/pr85164-1.c trunk/gcc/testsuite/gcc.dg/pr85164-2.c Modified: trunk/gcc/ChangeLog trunk/gcc/combine.c trunk/gcc/rtlanal.c trunk/gcc/testsuite/ChangeLog