[libcxx-commits] [libcxx] [libc++] avoid a GCC -Wsigned-compare warning where time_t is unsigned (PR #76560)
YAMAMOTO Takashi via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Dec 29 02:52:35 PST 2023
https://github.com/yamt created https://github.com/llvm/llvm-project/pull/76560
Note: For some reasons, GCC -Wall enables the warning for C++ while it doesn't for C.
Differential Revision: https://reviews.llvm.org/D143140
>From eb335965010d3356c549d297e246fe616c51d585 Mon Sep 17 00:00:00 2001
From: YAMAMOTO Takashi <yamamoto at midokura.com>
Date: Thu, 2 Feb 2023 17:05:52 +0900
Subject: [PATCH] [libc++] avoid a GCC -Wsigned-compare warning where time_t is
unsigned
Note: For some reasons, GCC -Wall enables the warning for C++
while it doesn't for C.
Differential Revision: https://reviews.llvm.org/D143140
---
libcxx/src/condition_variable.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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 {
More information about the libcxx-commits
mailing list