aboutsummaryrefslogtreecommitdiff
path: root/gcc/internal-fn.c
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2013-12-14 12:19:56 +0000
committerMarek Polacek <mpolacek@gcc.gnu.org>2013-12-14 12:19:56 +0000
commit7ddf4d5acea6123be6f3040e7306b5ea2cb2d651 (patch)
tree2e844b93e3888be3ca8df3f929abcce9323dcde9 /gcc/internal-fn.c
parente575540bb45f3cf9f82e557d6459fa59c998013b (diff)
downloadgcc-7ddf4d5acea6123be6f3040e7306b5ea2cb2d651.zip
gcc-7ddf4d5acea6123be6f3040e7306b5ea2cb2d651.tar.gz
gcc-7ddf4d5acea6123be6f3040e7306b5ea2cb2d651.tar.bz2
re PR sanitizer/59503 (Bogus integer-overflow error with long long with -m32)
PR sanitizer/59503 * internal-fn.c (ubsan_expand_si_overflow_addsub_check): Call expand_binop with correct optab depending on code. testsuite/ * c-c++-common/ubsan/pr59503.c: New test. From-SVN: r205984
Diffstat (limited to 'gcc/internal-fn.c')
-rw-r--r--gcc/internal-fn.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/gcc/internal-fn.c b/gcc/internal-fn.c
index ad9c947..a0874d4 100644
--- a/gcc/internal-fn.c
+++ b/gcc/internal-fn.c
@@ -214,14 +214,14 @@ ubsan_expand_si_overflow_addsub_check (tree_code code, gimple stmt)
/* Compute the operation. On RTL level, the addition is always
unsigned. */
- res = expand_binop (mode, add_optab, op0, op1,
- NULL_RTX, false, OPTAB_LIB_WIDEN);
+ res = expand_binop (mode, code == PLUS_EXPR ? add_optab : sub_optab,
+ op0, op1, NULL_RTX, false, OPTAB_LIB_WIDEN);
/* If the op1 is negative, we have to use a different check. */
emit_cmp_and_jump_insns (op1, const0_rtx, LT, NULL_RTX, mode,
false, sub_check, PROB_EVEN);
- /* Compare the result of the addition with one of the operands. */
+ /* Compare the result of the operation with one of the operands. */
emit_cmp_and_jump_insns (res, op0, code == PLUS_EXPR ? GE : LE,
NULL_RTX, mode, false, done_label,
PROB_VERY_LIKELY);