fold-const: Fix A <= 0 ? A : -A folding [PR95810]
We folded A <= 0 ? A : -A into -ABS (A), which is for signed integral types incorrect - can invoke on INT_MIN UB twice, once on ABS and once on its negation. The following patch fixes it by instead folding it to (type)-ABSU (A). 2020-06-24 Jakub Jelinek <jakub@redhat.com> PR middle-end/95810 * fold-const.c (fold_cond_expr_with_comparison): Optimize A <= 0 ? A : -A into (type)-absu(A) rather than -abs(A). * gcc.dg/ubsan/pr95810.c: New test. (cherry picked from commit 01e10b0ee77e82cb331414c569e02dc7a2c4999e)
Showing
gcc/testsuite/gcc.dg/ubsan/pr95810.c
0 → 100644
Please
register
or
sign in
to comment