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

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

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

commit r15-11050-ge3593aea97a561d083f927fa0ee9b9085aaf4626
Author: Nathaniel Shead <[email protected]>
Date:   Mon Apr 6 01:56:28 2026 +1000

    c++/modules: Fix entry-point detection for recursive clusters [PR118630]

    In r15-4861-g4a99443c5dd9a235022652ba0fb143c6370ea99d we added support
    to handle recursive dependency clusters, where we need to find the
    "entry" dependency that all other entities will hook off to ensure that
    we stream merge keys in the correct order on read-in.

    The logic I'd used to track the entry bit was not completely correct
    however, leading to assertion failures in 'sort_cluster' where we found
    that entities were not marked maybe_recursive when they should have
    been, or multiple entities were marked as the entry point.

    Consider a cycle of three entities in a cluster, 'A', 'B', and 'C',
    where 'A' is the entry point.  By definition we walk into 'A' first, and
    find one of the other entities, 'B'.  The old logic marked 'A' as the
    entry and 'B' as maybe-recursive; so far this is correct.

    But then if we walk into 'B' and find 'C' is maybe-recursive, the old
    logic would mark 'B' as the entry point (again!).  And likewise when we
    walk into 'C' and find 'A'.  So we would end up with three entry points.
    Similar issues could happen with other arrangements of dependencies.

    Instead, by aggressively marking everything we see as maybe-recursive,
    and only marking an entry point if nothing we see is maybe-recursive, we
    avoid this issue.  We should only be able to discover these other
    entities through the entry point (A) and so this 'flood fill' behaviour
    should ensure that all entities are correctly marked maybe-recursive,
    and only A is marked as an entry-point.

            PR c++/118630

    gcc/cp/ChangeLog:

            * module.cc (depset::hash::add_dependency): Correct entry point
            corection for recursive clusters.

    gcc/testsuite/ChangeLog:

            * g++.dg/modules/late-ret-5.h: New test.
            * g++.dg/modules/late-ret-5_a.H: New test.
            * g++.dg/modules/late-ret-5_b.C: New test.

    Signed-off-by: Nathaniel Shead <[email protected]>
    Reviewed-by: Jason Merrill <[email protected]>
    (cherry picked from commit 5265be568e5f106c8c538a3d82ea8def3dc5bcad)

Reply via email to