Case Study: The C++20 Migration Compiled Clean. A 40-Line Property Test Found the Ordering Break.
Описание и применение
Миграция библиотеки на C++20 изменила порядок сортировки записей, что выявилось только при помощи 40‑строчного теста свойств. Тест показал, что автоматический diff заменил ручной оператор сравнения на defaulted <=>, меняя порядок членов и, следовательно, сортировку.
Задача
Migrating a 2,400‑line library to C++20 changed the sort order of report records, breaking callers that relied on a specific priority‑timestamp‑name ordering.
Результат
The property test revealed that the defaulted comparison changed the ordering, exposing a regression that unit tests missed.
Рабочий процесс
- Snapshot existing test outputs’ SHA‑256
- Prompt model to apply only mechanical changes
- Apply diff and build with -std=c++20 -Wall -Wextra -Werror
- Run existing 14 unit tests
- Add ordering property test
- Run whole job under ASan and UBSan
Доказательства
The model’s reasoning was defensible. A defaulted <= > generates all six comparison operators, and operator< is synthesized from it.
The risky 13% was a single change to Record.
- Дата записи: 2026-09-09T05:15:22.782Z