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.
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 */