re PR sanitizer/81281 (UBSAN: false positive, dropped promotion to long type.)
authorJakub Jelinek <jakub@redhat.com>
Wed, 6 Dec 2017 19:22:06 +0000 (20:22 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 6 Dec 2017 19:22:06 +0000 (20:22 +0100)
commitd7f44d4d00640240af8731911eed207eca5ac4d0
treeb4e1816175ba649a8f594b1c017f750ae055d13a
parent9c1caf50e16b50903364709d774244928c719b35
re PR sanitizer/81281 (UBSAN: false positive, dropped promotion to long type.)

PR sanitizer/81281
* match.pd ((T)(P + A) - (T)P -> (T) A): Split into separate
simplify for plus with :c added, and pointer_plus without that.
((T)P - (T)(P + A) -> -(T) A): Likewise.  If type is integral
with undefined overflow and the conversion is not widening,
perform negation in utype and only convert to type afterwards.
((T)(P + A) - (T)(P + B) -> (T)A - (T)B): Split into separate
simplify for plus with :c added, and pointer_plus without that.
If type is integral with undefined overflow and the conversion is
not widening, perform minus in utype and only convert to type
afterwards.  Move the last pointer_diff_expr simplify into the
two outermost ifs.

* gcc.c-torture/execute/pr81281.c: New test.
* gcc.dg/pr81281-1.c: New test.
* gcc.dg/pr81281-2.c: New test.
* g++.dg/ubsan/pr81281.C: New test.
* g++.dg/ubsan/pr81281-aux.cc: New test.

From-SVN: r255449
gcc/ChangeLog
gcc/match.pd
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ubsan/pr81281-aux.cc [new file with mode: 0644]
gcc/testsuite/g++.dg/ubsan/pr81281.C [new file with mode: 0644]
gcc/testsuite/gcc.c-torture/execute/pr81281.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pr81281-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pr81281-2.c [new file with mode: 0644]