[PATCH 1/2] Merge mktime, timegm from upstream Gnulib

Florian Weimer fweimer@redhat.com
Thu Oct 18 20:12:00 GMT 2018


* Paul Eggert:

> [BZ #23603][BZ #16346]
> This fixes some obscure problems with integer overflow.

This patch breaks time/tst-mktime2 on armv7l-unknown-linux-gnueabihf,
with GCC 7.3:

tst-mktime2.c:70: numeric comparison failure
   left: -1 (0xffffffff); from: mktime (lt)
  right: 2147483647 (0x7fffffff); from: now
tst-mktime2.c:70: numeric comparison failure
   left: -1 (0xffffffff); from: mktime (lt)
  right: -2147483648 (0x80000000); from: now
tst-mktime2.c:70: numeric comparison failure
   left: -1 (0xffffffff); from: mktime (lt)
  right: 2147483646 (0x7ffffffe); from: now
tst-mktime2.c:70: numeric comparison failure
   left: -1 (0xffffffff); from: mktime (lt)
  right: -2147483647 (0x80000001); from: now
error: 4 test failures

This is after patching the test like this:

 65 static void
 66 mktime_test1 (time_t now)
 67 {
 68   struct tm *lt = localtime (&now);
 69   TEST_VERIFY_EXIT (lt != NULL);
 70   TEST_COMPARE (mktime (lt), now);
 71 }

(I will submit the test changes separately.)

Is this the expected new behavior on 32-bit architectures?

Thanks,
Florian



More information about the Libc-alpha mailing list