aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2017-05-26 09:31:36 +0000
committerMarek Polacek <mpolacek@gcc.gnu.org>2017-05-26 09:31:36 +0000
commit92f105f65dc6b370d098904c6726216c622cd64a (patch)
treeacc4df87aa5ee82ae9d6443013506dfff818fe46 /gcc/fold-const.c
parent74ca4e36fbb3ac796f29ef4d72e3cd496064d168 (diff)
downloadgcc-92f105f65dc6b370d098904c6726216c622cd64a.zip
gcc-92f105f65dc6b370d098904c6726216c622cd64a.tar.gz
gcc-92f105f65dc6b370d098904c6726216c622cd64a.tar.bz2
re PR sanitizer/80875 (UBSAN: compile time crash in fold_binary_loc at fold-const.c:9817)
PR sanitizer/80875 * fold-const.c (fold_binary_loc) <case MULT_EXPR>: Check if OP1 can be negated. * c-c++-common/ubsan/pr80875.c: New test. From-SVN: r248485
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index efc0b10..911ae36 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -9813,6 +9813,7 @@ fold_binary_loc (location_t loc,
if (TREE_CODE (op1) == INTEGER_CST
&& tree_int_cst_sgn (op1) == -1
&& negate_expr_p (op0)
+ && negate_expr_p (op1)
&& (tem = negate_expr (op1)) != op1
&& ! TREE_OVERFLOW (tem))
return fold_build2_loc (loc, MULT_EXPR, type,