diff options
author | Richard Biener <rguenther@suse.de> | 2017-06-20 12:46:46 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2017-06-20 12:46:46 +0000 |
commit | 531f0b3879b09b53d738b5bf84790c49bdd60977 (patch) | |
tree | 3c25275be71f3163116ccc276f24bd4c4a6d6d8e /gcc/fold-const.c | |
parent | c7a980b80b3a46ad24940269f6b85a75cdb94a60 (diff) | |
download | gcc-531f0b3879b09b53d738b5bf84790c49bdd60977.zip gcc-531f0b3879b09b53d738b5bf84790c49bdd60977.tar.gz gcc-531f0b3879b09b53d738b5bf84790c49bdd60977.tar.bz2 |
re PR sanitizer/81097 (UBSAN: false positive for not existing negation operator and a bogus message)
2017-06-20 Richard Biener <rguenther@suse.de>
PR middle-end/81097
* fold-const.c (split_tree): Fold to type before negating.
* c-c++-common/ubsan/pr81097.c: New testcase.
From-SVN: r249407
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 8559b1d..379a30e 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -853,9 +853,9 @@ split_tree (location_t loc, tree in, tree type, enum tree_code code, && code == PLUS_EXPR) { /* -X - 1 is folded to ~X, undo that here. Do _not_ do this - when IN is constant. */ - *minus_litp = build_one_cst (TREE_TYPE (in)); - var = negate_expr (TREE_OPERAND (in, 0)); + when IN is constant. Convert to TYPE before negating. */ + *minus_litp = build_one_cst (type); + var = negate_expr (fold_convert_loc (loc, type, TREE_OPERAND (in, 0))); } else var = in; |