Files
Alexey MilovidovandClaude Opus 4.8 52b78ebf15 Address review: make ipnsort move-based partition exception-safe
The move-based Hoare partition (`partition_hoare_branchy_cyclic`, used by
`::sort` for non-trivially-copyable types) saves an in-transit element in a
`Uninit<T>` union while shuffling. If the `is_less` comparator throws while
the gap is engaged, unwinding runs the union's trivial destructor, which never
calls `~T`, leaking the saved element and leaving the range one value short.
This is a regression versus the `pdqsort` path it replaces.

Add a `GapRestorer` RAII guard (mirroring `GapGuard` used by the
trivially-copyable block partition) that, on unwind, moves the saved element
back into the hole and destroys it. Add a unit test that throws from the
comparator at every comparison index in turn and asserts nothing is leaked.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
2026-06-08 17:53:23 +00:00
..
…
…

C++ port of ipnsort (unstable sort) by Lukas Bergdoll & Orson Peters. Upstream (Rust): https://github.com/Voultapher/sort-research-rs (ipnsort/). Dual-licensed MIT / Apache-2.0. See LICENSE.