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

--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <[email protected]>:

https://gcc.gnu.org/g:9082a3384ec5b4368b28e8dc85843947b1ccdc51

commit r17-4828-g9082a3384ec5b4368b28e8dc85843947b1ccdc51
Author: Odysseas Georgoudis <[email protected]>
Date:   Thu Oct 1 23:23:18 2026 +0100

    libstdc++: Make forward_list::sort exception-safe [PR124051]

    The bottom-up merge sort keeps its partially merged list in local
    pointers while the container head still points into the original chain.
    If the comparison throws after links have been changed, the head can
    refer to a cycle and some nodes are no longer reachable.

    Reconnect the merged prefix and both unconsumed runs, update the
    container head, and then rethrow.  This leaves every node reachable
    exactly once and preserves all iterators and references.  The success
    path still performs the same comparisons and link changes.

    libstdc++-v3/ChangeLog:

            PR libstdc++/124051
            * include/bits/forward_list.tcc (forward_list::sort): Restore the
            list before propagating an exception from the comparison
            * testsuite/23_containers/forward_list/operations/124051.cc: New
test.

    Signed-off-by: Odysseas Georgoudis <[email protected]>

Reply via email to