#include <stdio.h> #include <time.h> int main() { struct tm t2 = { 0, 0, 0, 1, 1, 2050 - 1900, 1, 1, 1}; time_t tt2 = mktime(&t2); printf("%ld\n"); return 0; } That should print -1, but instead it prints 2147483647. Sometime in 2063 mktime() starts returning -1 as it should.
In this case diff of approx_biennia of repaired_t0 and approx_requested_biennia is smaller than overflow_threshold (on 32-bit arches that's 21 biennia) and so mktime_internal sets *offset to a very large value and continues rather than returning -1 right away. Not sure where the code should find that the current timezone offset is not enough to undo the overflow.
I've fixed this in gnulib mktime.c; you can find the patch in: http://cvs.savannah.gnu.org/viewcvs/gnulib/lib/mktime.c?root=gnulib&r1=1.53&r2=1.54 Can you please port this patch back to glibc? Thanks.
I added the patch to cvs.