Commit 1ef532f4 by Marek Polacek Committed by Marek Polacek

re PR sanitizer/80348 (UBSAN: compile time crash in ubsan_instrument_division)

	PR sanitizer/80348
	* typeck.c (cp_build_binary_op): Convert COP[01] to ORIG_TYPE.

	* g++.dg/ubsan/div-by-zero-2.C: New test.

From-SVN: r246770
parent 29d8aae6
2017-04-07 Marek Polacek <polacek@redhat.com>
PR sanitizer/80348
* typeck.c (cp_build_binary_op): Convert COP[01] to ORIG_TYPE.
2017-04-05 Jakub Jelinek <jakub@redhat.com>
PR c++/80309
......
......@@ -5218,10 +5218,12 @@ cp_build_binary_op (location_t location,
original result_type. */
tree cop0 = op0;
tree cop1 = op1;
if (orig_type != NULL && result_type != orig_type)
if (orig_type != NULL_TREE)
{
cop0 = cp_convert (orig_type, op0, complain);
cop1 = cp_convert (orig_type, op1, complain);
if (TREE_TYPE (cop0) != orig_type)
cop0 = cp_convert (orig_type, op0, complain);
if (TREE_TYPE (cop1) != orig_type)
cop1 = cp_convert (orig_type, op1, complain);
}
instrument_expr = ubsan_instrument_division (location, cop0, cop1);
}
......
2017-04-07 Marek Polacek <polacek@redhat.com>
PR sanitizer/80348
* g++.dg/ubsan/div-by-zero-2.C: New test.
2017-04-07 Vladimir Makarov <vmakarov@redhat.com>
PR rtl-optimization/70478
......
// PR sanitizer/80348
// { dg-do compile }
// { dg-options "-fsanitize=integer-divide-by-zero" }
void
foo ()
{
if (0)
unsigned ((0 != 60806) > (0 != 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