match.pd
151 KB
-
re PR sanitizer/81281 (UBSAN: false positive, dropped promotion to long type.) · d7f44d4d
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
Jakub Jelinek committed