Skip to content

Commit 4151859

Browse files
[libc] Fix gmtime test on systems with sizeof(time_t) == 4 (#65388)
This test creates a time_t variable and assigns 0xfffffffffe1d7b01 which overflows the maximum time_t value for 64-bit time_t, then checks if the syscall fails and errno was set. In systems with sizeof(time_t) == 4, the value is narrowed down to 0xfe1d7b01 and doesn't overflow, causing the test to fail. This patch then disables the test on systems with 32 bits long time_t.
1 parent 492c1f3 commit 4151859

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

libc/test/src/time/gmtime_test.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ using __llvm_libc::testing::ErrnoSetterMatcher::Succeeds;
2020
using __llvm_libc::time_utils::TimeConstants;
2121

2222
TEST(LlvmLibcGmTime, OutOfRange) {
23+
if (sizeof(time_t) < sizeof(int64_t))
24+
return;
2325
time_t seconds =
2426
1 + INT_MAX * static_cast<int64_t>(
2527
TimeConstants::NUMBER_OF_SECONDS_IN_LEAP_YEAR);

0 commit comments

Comments
 (0)