changeset: 6834:0e0d54b5a384
user:      Kevin McCarthy <[email protected]>
date:      Wed Nov 02 18:54:06 2016 -0700
link:      http://dev.mutt.org/hg/mutt/rev/0e0d54b5a384

Attempt to silence a clang range warning. (closes #3891)

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.

diffs (15 lines):

diff -r 4da647a80c55 -r 0e0d54b5a384 date.c
--- a/date.c    Wed Nov 02 18:27:09 2016 -0700
+++ b/date.c    Wed Nov 02 18:54:06 2016 -0700
@@ -77,8 +77,9 @@
     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 */

Reply via email to