https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95810

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>:

https://gcc.gnu.org/g:01e10b0ee77e82cb331414c569e02dc7a2c4999e

commit r11-1620-g01e10b0ee77e82cb331414c569e02dc7a2c4999e
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Wed Jun 24 10:40:02 2020 +0200

    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  <ja...@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.

Reply via email to