[libcxx-commits] [libcxx] [libc++] Save duration/timeout locally for condition_variable waits (PR #148330)

John Sheu via libcxx-commits libcxx-commits at lists.llvm.org
Mon Jul 21 09:44:56 PDT 2025


================
@@ -188,9 +188,10 @@ public:
   _LIBCPP_HIDE_FROM_ABI cv_status wait_until(_Lock& __lock, const chrono::time_point<_Clock, _Duration>& __t) {
     shared_ptr<mutex> __mut = __mut_;
     unique_lock<mutex> __lk(*__mut);
+    const chrono::time_point<_Clock, _Duration> __t_local = __t;
----------------
johnsheu wrote:

Taking the parameter by-value is directly nonconforming, as the standard calls for the parameter to be taken by-const-ref.  This is a change that we cannot do without an amendment to the standard.

As @jwakely points out, taking the parameter by-const-ref and then making a copy internally, in addition to having the observable behavior of different timeout handling, also has a user-observable additional copy.

https://github.com/llvm/llvm-project/pull/148330


More information about the libcxx-commits mailing list