[libcxx-commits] [PATCH] D106182: [libc++] Tidy-up instances of __STDCPP_DEFAULT_NEW_ALIGNMENT__ in the tests

Arthur O'Dwyer via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Jul 16 13:02:21 PDT 2021


Quuxplusone requested changes to this revision.
Quuxplusone added a comment.
This revision now requires changes to proceed.

LGTM % comments. Requesting changes, but I don't really need to see it again.



================
Comment at: libcxx/test/std/containers/sequences/array/size_and_alignment.pass.cpp:47
+#if TEST_STD_VER >= 11
+struct TEST_ALIGNAS(TEST_ALIGNOF(std::max_align_t) * 2) TestType1 {
 
----------------
Since this is `>= 11`, do we even need `TEST_ALIGNXX`, or could this be straightforwardly `alignas(2 * alignof(std::max_align_t))`?


================
Comment at: libcxx/test/std/language.support/support.types/max_align_t.compile.pass.cpp:22-23
+  // P0767
+  static_assert(std::is_trivial<std::max_align_t>::value, "");
+  static_assert(std::is_standard_layout<std::max_align_t>::value, "");
+#else
----------------
I believe it's safe to test these two traits in all modes. Just don't test `is_pod` unless `TEST_STD_VER <= 17`.


================
Comment at: libcxx/test/std/language.support/support.types/max_align_t.compile.pass.cpp:30
+static_assert(std::alignment_of<std::max_align_t>::value >= std::alignment_of<void*>::value,"");
+static_assert(std::alignment_of<std::max_align_t>::value <= __STDCPP_DEFAULT_NEW_ALIGNMENT__,
+              "max_align_t alignment should be no larger than operator new's alignment");
----------------
Since this is `UNSUPPORTED: c++03`, I think it's safe to use `alignof(std::max_align_t)` throughout instead of `std::alignment_of<std::max_align_t>::value`. `std::alignment_of` is at least en route to deprecation, if not there yet, and it'll be one less thing to worry about in the future.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106182/new/

https://reviews.llvm.org/D106182



More information about the libcxx-commits mailing list