[libcxx-commits] [libcxx] [libc++][C++26] P2562R1: `constexpr` Stable Sorting (PR #110320)
A. Jiang via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Oct 14 23:12:01 PDT 2024
================
@@ -148,22 +228,32 @@ int main(int, char**)
test_sort_<6>();
test_sort_<7>();
test_sort_<8>();
+ }
- test_larger_sorts(256);
- test_larger_sorts(257);
- test_larger_sorts(499);
- test_larger_sorts(500);
- test_larger_sorts(997);
- test_larger_sorts(1000);
- test_larger_sorts(1009);
-
-#if !defined(TEST_HAS_NO_EXCEPTIONS)
- { // check that the algorithm works without memory
- std::vector<int> vec(150, 3);
- getGlobalMemCounter()->throw_after = 0;
- std::stable_sort(vec.begin(), vec.end());
- }
-#endif // !defined(TEST_HAS_NO_EXCEPTIONS)
+ { // larger sorts
+ // run- and conditionally compile-time tests
+ test_larger_sorts<256>();
+ test_larger_sorts<257>();
+#if TEST_STD_VER >= 26
+ static_assert((test_larger_sorts<256>(), true));
+ static_assert((test_larger_sorts<257>(), true));
+#endif
----------------
frederick-vs-ja wrote:
I found that the previously failed generic-abi-unstable and generic-ubsan CI tesing use unstable ABI (where `_LIBCPP_ABI_VERSION` is `2`). It seems that the new ABI causes more steps in evaluations in this file. So I guess we can skip these for new ABI.
```suggestion
#if TEST_STD_VER >= 26 && _LIBCPP_ABI_VERSION == 1
static_assert((test_larger_sorts<256>(), true));
static_assert((test_larger_sorts<257>(), true));
#endif
```
Hmm... however, it seems that there should be a non-`_UGLY` macro indicating `_LIBCPP_ABI_VERSION` in `test_macros.h` and test files shouldn't use libc++-specific `_UGLY` macros.
Perhaps we can add this (note that at least MSVC STL also relies libc++'s test suite) and use it:
```C++
#ifdef _LIBCPP_ABI_VERSION
# define TEST_LIBCPP_ABI_VERSION _LIBCPP_ABI_VERSION
#else
# define TEST_LIBCPP_ABI_VERSION 0
#endif
```
But I'm unsure how should these conditions interact with other implementations.
CC @ldionne @philnik777 @StephanTLavavej.
https://github.com/llvm/llvm-project/pull/110320
More information about the libcxx-commits
mailing list