Commit 92f105f6 by Marek Polacek Committed by Marek Polacek

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
parent 74ca4e36
2017-05-26 Marek Polacek <polacek@redhat.com>
PR sanitizer/80875
* fold-const.c (fold_binary_loc) <case MULT_EXPR>: Check if OP1
can be negated.
2017-05-26 Richard Biener <rguenther@suse.de> 2017-05-26 Richard Biener <rguenther@suse.de>
PR tree-optimization/80842 PR tree-optimization/80842
......
...@@ -9813,6 +9813,7 @@ fold_binary_loc (location_t loc, ...@@ -9813,6 +9813,7 @@ fold_binary_loc (location_t loc,
if (TREE_CODE (op1) == INTEGER_CST if (TREE_CODE (op1) == INTEGER_CST
&& tree_int_cst_sgn (op1) == -1 && tree_int_cst_sgn (op1) == -1
&& negate_expr_p (op0) && negate_expr_p (op0)
&& negate_expr_p (op1)
&& (tem = negate_expr (op1)) != op1 && (tem = negate_expr (op1)) != op1
&& ! TREE_OVERFLOW (tem)) && ! TREE_OVERFLOW (tem))
return fold_build2_loc (loc, MULT_EXPR, type, return fold_build2_loc (loc, MULT_EXPR, type,
......
2017-05-26 Marek Polacek <polacek@redhat.com>
PR sanitizer/80875
* c-c++-common/ubsan/pr80875.c: New test.
2017-05-26 Tom de Vries <tom@codesourcery.com> 2017-05-26 Tom de Vries <tom@codesourcery.com>
PR testsuite/80557 PR testsuite/80557
......
/* PR sanitizer/80875 */
/* { dg-do compile } */
/* { dg-options "-fsanitize=undefined" } */
int
foo (void)
{
return ~__INT_MAX__ * (0 / 0); /* { dg-warning "division by zero" } */
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment