mirror of
https://github.com/hanzoai/datastore.git
synced 2026-09-26 13:55:07 +00:00
The driftsort scratch buffer is reinterpreted as `T *` and accessed as `T &`, so it must satisfy `alignof(T)`. The stack buffer uses `alignas(T)`, but the heap path allocated with plain `new std::byte[]`, which only guarantees the default new alignment. For an over-aligned trivially-copyable `T` (e.g. `alignas(64)`) on the heap path this produced under-aligned `T` references. Allocate the heap scratch with aligned `operator new[]` plus a matching aligned `operator delete[]` deleter. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
C++ port of driftsort (stable sort) by Orson Peters & Lukas Bergdoll. Upstream (Rust): https://github.com/Voultapher/driftsort. Dual-licensed MIT / Apache-2.0. See LICENSE.