[PATCH] Fix UB in prepare_cmp_insn (PR middle-end/89281)

Eric Botcazou ebotcazou@adacore.com
Tue Feb 12 23:51:00 GMT 2019


> The following hunk of code results in UB on the recently added testcase,
> because if cmp_mode is SImode or DImode, then 1 << 32 or 1 << 64 is
> undefined.  Fixed by using GET_MODE_MASK, plus UINTVAL because size is
> really unsigned (code later on uses unsignedp=1 too).

Doesn't the current check make sure that the RTL constant is valid for the 
mode though (since RTL constants are sign-extended for their mode)?  See 
emit_block_move_via_movmem for an equivalent check with GET_MODE_MASK >> 1.

-- 
Eric Botcazou



More information about the Gcc-patches mailing list