re PR sanitizer/80349 (UBSAN: compile time crash with "type mismatch in binary expression" message)

PR sanitizer/80349
	* fold-const.c (fold_binary_loc) <case BIT_IOR_EXPR>: Convert arg0's
	first argument to type.

	* g++.dg/ubsan/pr80349.C: New test.

From-SVN: r246865
This commit is contained in:
Jakub Jelinek 2017-04-12 08:12:26 +02:00 committed by Jakub Jelinek
parent 31d61ac600
commit d62e6f1078
4 changed files with 28 additions and 6 deletions

View File

@ -1,3 +1,9 @@
2017-04-12 Jakub Jelinek <jakub@redhat.com>
PR sanitizer/80349
* fold-const.c (fold_binary_loc) <case BIT_IOR_EXPR>: Convert arg0's
first argument to type.
2017-04-11 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
PR target/80376

View File

@ -9916,12 +9916,12 @@ fold_binary_loc (location_t loc,
}
if (c3 != c1)
return fold_build2_loc (loc, BIT_IOR_EXPR, type,
fold_build2_loc (loc, BIT_AND_EXPR, type,
TREE_OPERAND (arg0, 0),
wide_int_to_tree (type,
c3)),
arg1);
{
tem = fold_convert_loc (loc, type, TREE_OPERAND (arg0, 0));
tem = fold_build2_loc (loc, BIT_AND_EXPR, type, tem,
wide_int_to_tree (type, c3));
return fold_build2_loc (loc, BIT_IOR_EXPR, type, tem, arg1);
}
}
/* See if this can be simplified into a rotate first. If that

View File

@ -1,3 +1,8 @@
2017-04-12 Jakub Jelinek <jakub@redhat.com>
PR sanitizer/80349
* g++.dg/ubsan/pr80349.C: New test.
2017-04-11 Jakub Jelinek <jakub@redhat.com>
PR c++/80370

View File

@ -0,0 +1,11 @@
// PR sanitizer/80349
// { dg-do compile }
// { dg-options "-fsanitize=undefined" }
extern const long long int v;
void
foo ()
{
(int)((v & 50 | 051UL) << 0) << 0;
}