public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/redhat/heads/gcc-8-branch)] Fix filesystem::last_write_time failure with 32-bit time_t
@ 2020-09-17 17:14 Jakub Jelinek
0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2020-09-17 17:14 UTC (permalink / raw)
To: gcc-cvs, libstdc++-cvs
https://gcc.gnu.org/g:86b91f4791f21fe0db38b79b5cd57b7557c4c88d
commit 86b91f4791f21fe0db38b79b5cd57b7557c4c88d
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Thu Jan 10 15:39:28 2019 +0000
Fix filesystem::last_write_time failure with 32-bit time_t
* testsuite/27_io/filesystem/operations/last_write_time.cc: Fix
test failures on targets with 32-bit time_t.
(cherry picked from commit 174f1d264274d3f77133713a3853fc016ba527b4)
Diff:
---
.../27_io/filesystem/operations/last_write_time.cc | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/last_write_time.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/last_write_time.cc
index 1fdf39c7e0d..c815e01a5c6 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/operations/last_write_time.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/last_write_time.cc
@@ -22,6 +22,7 @@
// 15.25 Permissions [fs.op.last_write_time]
#include <filesystem>
+#include <limits>
#include <testsuite_fs.h>
#include <testsuite_hooks.h>
@@ -141,14 +142,27 @@ test02()
VERIFY( !ec );
VERIFY( approx_equal(last_write_time(f.path), time) );
+ if (std::numeric_limits<std::time_t>::max()
+ < std::numeric_limits<std::int64_t>::max())
+ return; // file clock's epoch is out of range for 32-bit time_t
+
ec = bad_ec;
+ // The file clock's epoch:
time = time_type();
last_write_time(f.path, time, ec);
VERIFY( !ec );
VERIFY( approx_equal(last_write_time(f.path), time) );
ec = bad_ec;
- time -= std::chrono::milliseconds(1000 * 60 * 10 + 15);
+ // A time after the epoch
+ time += std::chrono::milliseconds(1000 * 60 * 10 + 15);
+ last_write_time(f.path, time, ec);
+ VERIFY( !ec );
+ VERIFY( approx_equal(last_write_time(f.path), time) );
+
+ ec = bad_ec;
+ // A time before than the epoch
+ time -= std::chrono::milliseconds(1000 * 60 * 20 + 15);
last_write_time(f.path, time, ec);
VERIFY( !ec );
VERIFY( approx_equal(last_write_time(f.path), time) );
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-09-17 17:14 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-17 17:14 [gcc(refs/vendors/redhat/heads/gcc-8-branch)] Fix filesystem::last_write_time failure with 32-bit time_t Jakub Jelinek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).