Commit d62e6f10 by Jakub Jelinek Committed by Jakub Jelinek

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
parent 31d61ac6
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> 2017-04-11 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
PR target/80376 PR target/80376
......
...@@ -9916,12 +9916,12 @@ fold_binary_loc (location_t loc, ...@@ -9916,12 +9916,12 @@ fold_binary_loc (location_t loc,
} }
if (c3 != c1) if (c3 != c1)
return fold_build2_loc (loc, BIT_IOR_EXPR, type, {
fold_build2_loc (loc, BIT_AND_EXPR, type, tem = fold_convert_loc (loc, type, TREE_OPERAND (arg0, 0));
TREE_OPERAND (arg0, 0), tem = fold_build2_loc (loc, BIT_AND_EXPR, type, tem,
wide_int_to_tree (type, wide_int_to_tree (type, c3));
c3)), return fold_build2_loc (loc, BIT_IOR_EXPR, type, tem, arg1);
arg1); }
} }
/* See if this can be simplified into a rotate first. If that /* See if this can be simplified into a rotate first. If that
......
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> 2017-04-11 Jakub Jelinek <jakub@redhat.com>
PR c++/80370 PR c++/80370
......
// PR sanitizer/80349
// { dg-do compile }
// { dg-options "-fsanitize=undefined" }
extern const long long int v;
void
foo ()
{
(int)((v & 50 | 051UL) << 0) << 0;
}
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