[libcxx-commits] [libcxx] [libc++][test] Use `LIBCPP_STATIC_ASSERT` to deal with `noexcept` strengthening (PR #74254)
Stephan T. Lavavej via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Dec 3 14:24:29 PST 2023
================
@@ -141,12 +141,12 @@ constexpr void test_mdspan_types(const H& handle, const M& map, const A& acc) {
ASSERT_SAME_TYPE(decltype(m.is_unique()), bool);
ASSERT_SAME_TYPE(decltype(m.is_exhaustive()), bool);
ASSERT_SAME_TYPE(decltype(m.is_strided()), bool);
- assert(!noexcept(MDS::is_always_unique()));
- assert(!noexcept(MDS::is_always_exhaustive()));
- assert(!noexcept(MDS::is_always_strided()));
- assert(!noexcept(m.is_unique()));
- assert(!noexcept(m.is_exhaustive()));
- assert(!noexcept(m.is_strided()));
+ LIBCPP_STATIC_ASSERT(!noexcept(MDS::is_always_unique()));
----------------
StephanTLavavej wrote:
@crtrott can answer definitively, but it appeared to me that these tests were semi-mechanically translating the Standardese, and it was a simple oversight that implementations don't have to follow the absence of `noexcept` in the Standard.
For `mdspan::is_always_meow()`, there's a simple proof that the Standard could absolutely mark them as unconditionally `noexcept`. [N4964](https://isocpp.org/files/papers/N4964.pdf) \[mdspan.mdspan.overview\] requires `mdspan::is_always_meow()` to be effects-equivalent-to `{ return mapping_type::is_always_meow(); }`, then the layout mapping requirements in \[mdspan.layout.reqmts\]/22, /24, /26 require `mapping_type::is_always_meow()` to be a constant expression. This could likely be resolved through a simple LWG issue.
For the other `mdspan` operations involved here (construction/`is_meow`/`stride`), we have conditionally strengthened them, and the Standard doesn't usually depict conditional `noexcept` unless it's really important, so that's likely the reason.
https://github.com/llvm/llvm-project/pull/74254
More information about the libcxx-commits
mailing list