diff options
author | Richard Biener <rguenther@suse.de> | 2017-08-04 10:33:39 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2017-08-04 10:33:39 +0000 |
commit | 165b2f5f5d7fe14ab567e83a4cf2e0a492038a8c (patch) | |
tree | a6eeeef546385086a7ce0dc6f4b34426958c7fff /gcc/fold-const.c | |
parent | 54cb4e20069f00f96ad2b6249cb68295a61a1786 (diff) | |
download | gcc-165b2f5f5d7fe14ab567e83a4cf2e0a492038a8c.zip gcc-165b2f5f5d7fe14ab567e83a4cf2e0a492038a8c.tar.gz gcc-165b2f5f5d7fe14ab567e83a4cf2e0a492038a8c.tar.bz2 |
re PR middle-end/81705 (UBSAN: yet another false positive)
2017-08-04 Richard Biener <rguenther@suse.de>
PR middle-end/81705
* fold-const.c (fold_binary_loc): Properly restrict
minus_var0 && minus_var1 case when associating undefined overflow
entities.
* c-c++-common/ubsan/pr81705.c: New testcase.
From-SVN: r250866
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index ed6c289..53428b89 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -9592,12 +9592,13 @@ fold_binary_loc (location_t loc, if (POINTER_TYPE_P (atype) || (INTEGRAL_TYPE_P (atype) && !TYPE_OVERFLOW_WRAPS (atype))) { - if (var0 && var1) + if ((var0 && var1) || (minus_var0 && minus_var1)) { /* ??? If split_tree would handle NEGATE_EXPR we could - simplify this down to the var0/minus_var1 cases. */ - tree tmp0 = var0; - tree tmp1 = var1; + simply reject these cases and the allowed cases would + be the var0/minus_var1 ones. */ + tree tmp0 = var0 ? var0 : minus_var0; + tree tmp1 = var1 ? var1 : minus_var1; bool one_neg = false; if (TREE_CODE (tmp0) == NEGATE_EXPR) |