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

--- Comment #7 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:a4c2e62d60f47d47cdd94951e16b0de50495cdab

commit r12-6221-ga4c2e62d60f47d47cdd94951e16b0de50495cdab
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Wed Jan 5 10:45:26 2022 +0100

    gimple-fold: Remove incorrect folding of debug stmts [PR103691]

    For ADDR_EXPR gimple_debug_bind_get_value fold_stmt_1 uses
    maybe_canonicalize_mem_ref_addr earlier and I think that should
    resolve the concerns raised in PR52329.  But folding ADDR_EXPR
    operand using maybe_fold_reference and then taking address of that
    looks like an invalid transformation, it can transform
      # DEBUG D.4293 => &a[0]
    into
      # DEBUG D.4293 => &2.0e+0
    etc., all we want to allow are the lhs folding of the operand which
    maybe_fold_reference no longer does since r12-21-g0bf8cd9d5e8ac.

    2022-01-05  Jakub Jelinek  <ja...@redhat.com>

            PR fortran/103691
            * gimple-fold.c (fold_stmt_1): Don't call maybe_fold_reference
            for DEBUG stmts with ADDR_EXPR gimple_debug_bind_get_value,
            it can do unwanted rhs folding like &a[0] into &2.0 etc.

            * gfortran.dg/pr103691.f90: New test.

Reply via email to