]> granicus.if.org Git - neomutt/commitdiff
Attempt to silence a clang range warning. (closes #3891)
authorKevin McCarthy <kevin@8t8.us>
Thu, 3 Nov 2016 01:54:06 +0000 (18:54 -0700)
committerKevin McCarthy <kevin@8t8.us>
Thu, 3 Nov 2016 01:54:06 +0000 (18:54 -0700)
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

diff --git a/date.c b/date.c
index 6fd7eaf9311c80deddf4ea2227f52a0e31d2407a..43fbeced05cddd951d972a0a711e538c96e7bafb 100644 (file)
--- 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 */