aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2017-04-12 08:12:26 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2017-04-12 08:12:26 +0200
commitd62e6f1078dd62f6e8937d1f48f1f77f0a78e19e (patch)
tree3c5094f94841ffdb7f90d3632cb0157e88a7e98a /gcc/fold-const.c
parent31d61ac600b2a6e8b80d0e27d11ec8d4720780ea (diff)
downloadgcc-d62e6f1078dd62f6e8937d1f48f1f77f0a78e19e.zip
gcc-d62e6f1078dd62f6e8937d1f48f1f77f0a78e19e.tar.gz
gcc-d62e6f1078dd62f6e8937d1f48f1f77f0a78e19e.tar.bz2
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
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 524bb0f..2f2e93a 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -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