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

--- Comment #6 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-15 branch has been updated by Richard Biener
<[email protected]>:

https://gcc.gnu.org/g:c3df52a35de6ee04837244d73c224e6f93834a21

commit r15-11230-gc3df52a35de6ee04837244d73c224e6f93834a21
Author: Richard Biener <[email protected]>
Date:   Mon Apr 13 13:18:00 2026 +0200

    tree-optimization/124868 - path isolation wrong-code

    The path isolation code mishandles the case where in the same block
    there's both a return of a local variable and a dereference of zero
    but from different edges.  In this case we re-use the produced block
    copy for both isolated paths, causing a trap on the path to the
    return of a non-local.

    The least intrusive change I came up with separates both causes
    and transforms, first isolating NULL dereferences and then
    isolating returns of non-NULL.  This will skip the latter transform
    on paths which will now not return anyway.

    To avoid duplicate diagnostics the handle_return_addr_local_phi_arg
    only diagnoses cases in blocks dominated by the original block, not in
    copies which still need SSA update and thus are falsely visited.

            PR tree-optimization/124868
            * gimple-ssa-isolate-paths.cc (handle_return_addr_local_phi_arg):
            Do not diagnose returns in blocks not dominated by the PHI.
            (find_implicit_erroneous_behavior): Do two sweeps over PHIs,
            first for NULL dereferences and then for local address returns.

            * gcc.dg/torture/pr124868.c: New testcase.

    (cherry picked from commit 935d483a80c7ab96d4e483e62a5c2cc138409ed3)

Reply via email to