From db77e2bfd274d6bb535c34ef51d04e6907397978 Mon Sep 17 00:00:00 2001 From: Kevin McCarthy Date: Wed, 2 Nov 2016 18:54:06 -0700 Subject: [PATCH] Attempt to silence a clang range warning. (closes #3891) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit When TM_YEAR_MAX > INT_MAX, clang complains the comparison is always false. Note that this is really a compiler bug, which was fixed by gcc 9 years ago. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=12963 Thanks to Vincent Lefèvre for the suggested fix and the gcc bug reference. --- date.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/date.c b/date.c index 6fd7eaf9..43fbeced 100644 --- a/date.c +++ b/date.c @@ -77,8 +77,9 @@ time_t mutt_mktime (struct tm *t, int local) 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 }; - /* Prevent an integer overflow */ - if (t->tm_year > TM_YEAR_MAX) + /* Prevent an integer overflow. + * The time_t cast is an attempt to silence a clang range warning. */ + if ((time_t)t->tm_year > TM_YEAR_MAX) return TIME_T_MAX; /* Compute the number of days since January 1 in the same year */ -- 2.50.1