diff options
author | Marek Polacek <polacek@redhat.com> | 2017-06-07 11:19:40 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2017-06-07 11:19:40 +0000 |
commit | 0874a778ec0adf43167dd4aa014dadb75b0907f8 (patch) | |
tree | e331107548064bd858fc2e2c59ff591607aa438a /gcc/fold-const.c | |
parent | 55e872a462ca506350140451ad4a170d6baa462b (diff) | |
download | gcc-0874a778ec0adf43167dd4aa014dadb75b0907f8.zip gcc-0874a778ec0adf43167dd4aa014dadb75b0907f8.tar.gz gcc-0874a778ec0adf43167dd4aa014dadb75b0907f8.tar.bz2 |
re PR sanitizer/80932 (UBSAN: false positive as a result of distribution: c1*(c2*v1-c3*v2)=>c1*c2*v1-c1*c3*v2)
PR sanitizer/80932
* fold-const.c (extract_muldiv_1) <case MINUS_EXPR>: Add
TYPE_OVERFLOW_WRAPS check.
* c-c++-common/ubsan/pr80932.c: New test.
From-SVN: r248961
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index b0d03c9..f3975c7 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -6178,6 +6178,7 @@ extract_muldiv_1 (tree t, tree c, enum tree_code code, tree wide_type, t1 = extract_muldiv (op0, c, code, wide_type, &sub_strict_overflow_p); t2 = extract_muldiv (op1, c, code, wide_type, &sub_strict_overflow_p); if (t1 != 0 && t2 != 0 + && TYPE_OVERFLOW_WRAPS (ctype) && (code == MULT_EXPR /* If not multiplication, we can only do this if both operands are divisible by c. */ |