re PR sanitizer/80932 (UBSAN: false positive as a result of distribution: c1*(c2*v1-c3*v2)=>c1*c2*v1-c1*c3*v2)

PR sanitizer/80932
	* fold-const.c (extract_muldiv_1) <case MINUS_EXPR>: Add
	TYPE_OVERFLOW_WRAPS check. 

	* c-c++-common/ubsan/pr80932.c: New test.

From-SVN: r248961
This commit is contained in:
Marek Polacek 2017-06-07 11:19:40 +00:00 committed by Marek Polacek
parent 55e872a462
commit 0874a778ec
4 changed files with 29 additions and 0 deletions

View File

@ -1,3 +1,9 @@
2017-06-07 Marek Polacek <polacek@redhat.com>
PR sanitizer/80932
* fold-const.c (extract_muldiv_1) <case MINUS_EXPR>: Add
TYPE_OVERFLOW_WRAPS check.
2017-06-07 Bin Cheng <bin.cheng@arm.com>
* tree-vect-loop-manip.c (vect_do_peeling): Don't skip vector loop

View File

@ -6178,6 +6178,7 @@ extract_muldiv_1 (tree t, tree c, enum tree_code code, tree wide_type,
t1 = extract_muldiv (op0, c, code, wide_type, &sub_strict_overflow_p);
t2 = extract_muldiv (op1, c, code, wide_type, &sub_strict_overflow_p);
if (t1 != 0 && t2 != 0
&& TYPE_OVERFLOW_WRAPS (ctype)
&& (code == MULT_EXPR
/* If not multiplication, we can only do this if both operands
are divisible by c. */

View File

@ -1,3 +1,8 @@
2017-06-07 Marek Polacek <polacek@redhat.com>
PR sanitizer/80932
* c-c++-common/ubsan/pr80932.c: New test.
2017-06-07 Bin Cheng <bin.cheng@arm.com>
* gcc.target/i386/l_fma_double_1.c: Adjust test strings.

View File

@ -0,0 +1,17 @@
/* PR sanitizer/80932 */
/* { dg-do run } */
/* { dg-options "-fsanitize=undefined -fsanitize-undefined-trap-on-error" } */
int x = 1;
long int
foo (void)
{
return ((long) (13801962912760474560ULL * x) - (long) (15334142073106273231ULL * x)) * -6;
}
int
main ()
{
foo ();
}