From: Tim Kientzle Date: Mon, 7 Nov 2011 01:52:00 +0000 (-0500) Subject: Assign the intermediate value to a variable to X-Git-Tag: v3.0.0a~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3d89be7123255aafa72e73bfe501699b5edae21b;p=thirdparty%2Flibarchive.git Assign the intermediate value to a variable to prevent compiler optimizations from breaking the test. SVN-Revision: 3757 --- diff --git a/libarchive/test/test_read_format_mtree.c b/libarchive/test/test_read_format_mtree.c index 304bb5876..ef8782a9e 100644 --- a/libarchive/test/test_read_format_mtree.c +++ b/libarchive/test/test_read_format_mtree.c @@ -37,7 +37,7 @@ test_read_format_mtree1(void) // without relying on overflow. This assumes that long long // is at least 64 bits. const static long long max_int64 = ((((long long)1) << 62) - 1) + (((long long)1) << 62); - time_t min_time; + time_t min_time, t; extract_reference_file(reffile); @@ -137,7 +137,9 @@ test_read_format_mtree1(void) /* Verify min_time is the smallest possible time_t. */ min_time = archive_entry_mtime(ae); assert(min_time <= 0); - assert(min_time - 1 > 0); + /* Simply asserting min_time - 1 > 0 breaks with some compiler optimizations. */ + t = min_time - 1; + assert(t > 0); /* toooldfile is 1 sec older, which should overflow and get returned * with the same value. */