commit 68908239cf8c8987ce4693f6769709f8f5b9fbc3 Author: Jonathan Wakely Date: Thu Jan 10 15:38:31 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. 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 7a693a1ddcb..3f31375f51b 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 +#include #include #include @@ -141,14 +142,27 @@ test02() VERIFY( !ec ); VERIFY( approx_equal(last_write_time(f.path), time) ); + if (std::numeric_limits::max() + < std::numeric_limits::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) );