From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2153) id B6B9539FE49D; Thu, 17 Sep 2020 17:14:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B6B9539FE49D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1600362846; bh=4fr4w7uizRH9hsset4jAH/sRvSWQkrMUdsE2wTYfb+E=; h=From:To:Subject:Date:From; b=X91qrhdVyIBjwTtTrekq5Uph1kVEIHatNggNOjRmxStFa/+NkWRxi1dn+MoquPePk T5UtnC6WHshPpgnTVl5BPahmdBolba8Snr96eiFHeXmLxgrbcGUtiM3LJkDimH2O+E QesoErClzHXZ8IazBNfIShUFCs2PAbx3yfCzHjow= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Jakub Jelinek To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc(refs/vendors/redhat/heads/gcc-8-branch)] Fix filesystem::last_write_time failure with 32-bit time_t X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/vendors/redhat/heads/gcc-8-branch X-Git-Oldrev: 0678d1aadaa9435992adfa0bc10f916c697b5407 X-Git-Newrev: 86b91f4791f21fe0db38b79b5cd57b7557c4c88d Message-Id: <20200917171406.B6B9539FE49D@sourceware.org> Date: Thu, 17 Sep 2020 17:14:06 +0000 (GMT) X-BeenThere: libstdc++-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Sep 2020 17:14:06 -0000 https://gcc.gnu.org/g:86b91f4791f21fe0db38b79b5cd57b7557c4c88d commit 86b91f4791f21fe0db38b79b5cd57b7557c4c88d Author: Jonathan Wakely 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 +#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) );