[libcxx-commits] [libcxx] [libc++] avoid a GCC -Wsigned-compare warning where time_t is unsigned (PR #76560)

via libcxx-commits libcxx-commits at lists.llvm.org
Fri Dec 29 02:53:00 PST 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libcxx

Author: YAMAMOTO Takashi (yamt)

<details>
<summary>Changes</summary>

Note: For some reasons, GCC -Wall enables the warning for C++ while it doesn't for C.

Differential Revision: https://reviews.llvm.org/D143140

---
Full diff: https://github.com/llvm/llvm-project/pull/76560.diff


1 Files Affected:

- (modified) libcxx/src/condition_variable.cpp (+1-1) 


``````````diff
diff --git a/libcxx/src/condition_variable.cpp b/libcxx/src/condition_variable.cpp
index db60571cf5f560..d82d990da33fc8 100644
--- a/libcxx/src/condition_variable.cpp
+++ b/libcxx/src/condition_variable.cpp
@@ -44,7 +44,7 @@ void condition_variable::__do_timed_wait(unique_lock<mutex>& lk,
   seconds s = duration_cast<seconds>(d);
   typedef decltype(ts.tv_sec) ts_sec;
   constexpr ts_sec ts_sec_max = numeric_limits<ts_sec>::max();
-  if (s.count() < ts_sec_max) {
+  if ((unsigned long long)s.count() < ts_sec_max) {
     ts.tv_sec  = static_cast<ts_sec>(s.count());
     ts.tv_nsec = static_cast<decltype(ts.tv_nsec)>((d - s).count());
   } else {

``````````

</details>


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


More information about the libcxx-commits mailing list