[libcxx-commits] [PATCH] D110042: [libc++] counting_semaphore should not be default-constructible

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Sep 20 17:02:23 PDT 2021


ldionne accepted this revision.
ldionne added a comment.
This revision is now accepted and ready to land.

LGTM with my suggestion, which should fix the CI.



================
Comment at: libcxx/test/std/thread/thread.semaphore/ctor.compile.pass.cpp:12-14
+// This test requires the dylib support introduced in D68480, which shipped in
+// macOS 11.0.
+// XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11|12|13|14|15}}
----------------
You need to remove this since this is a `compile.pass.cpp` test -- it won't fail because of back-deployment.


================
Comment at: libcxx/test/std/thread/thread.semaphore/ctor.compile.pass.cpp:32-33
+#if 0 // TODO FIXME: the ctor should be constexpr when TEST_STD_VER > 17
+constinit std::binary_semaphore bs(1);
+constinit std::counting_semaphore cs(1);
+#endif
----------------
Quuxplusone wrote:
> ldionne wrote:
> > Please follow the usual pattern of running the code in a conditionally-`constexpr` function and calling it from `main`.
> Unfortunately we cannot do that, because `counting_semaphore` is constexpr-constructible but //not// constexpr-destructible. (I almost asked "what is the use of such a constexpr constructor" in Slack myself, but as I was typing the question, figured out that the purpose is so that we can use semaphores with C++20 `constinit`. So that's what I did here.)
Understood, thanks for explaining.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110042



More information about the libcxx-commits mailing list