aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2019-01-10 15:39:28 +0000
committerJonathan Wakely <jwakely@redhat.com>2020-08-07 12:42:48 +0100
commit3b05a417774d40cf1b9fca61630209de8338ba47 (patch)
tree2d5b6af317e7bcb8f3ca4d8e61a71f236e1886f0 /libstdc++-v3
parent01cbd26b022cc9d4eaf26287b48299acfce80348 (diff)
downloadgcc-3b05a417774d40cf1b9fca61630209de8338ba47.zip
gcc-3b05a417774d40cf1b9fca61630209de8338ba47.tar.gz
gcc-3b05a417774d40cf1b9fca61630209de8338ba47.tar.bz2
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)
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/testsuite/27_io/filesystem/operations/last_write_time.cc16
1 files changed, 15 insertions, 1 deletions
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 1fdf39c..c815e01 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) );