
Hello! With my hat of the tzdata/tzcode maintainer on the FreeBSD system, I sometimes get the more interesting bugs reported. For example this piece of code, on 64 bit machines it returns the same values for values bigger than the initial one: #include <errno.h> #include <stdint.h> #include <stdio.h> #include <time.h> void t_inspect(time_t t) { struct tm *tp; errno = 0; tp = gmtime(&t); printf("t: %ld, tp: %p errno: %d\n", t, tp, errno); if (tp) printf("sec: %d, min: %d, hour: %d, mday: %d, mon: %d, " "year: %d, wday: %d, yday: %d, isdst: %d, gmtoff: %ld, " "zone: %s\n", tp->tm_sec, tp->tm_min, tp->tm_hour, tp->tm_mday, tp->tm_mon, tp->tm_year, tp->tm_wday, tp->tm_yday, tp->tm_isdst, tp->tm_gmtoff, tp->tm_zone); } int main(void) { // time_t t = INT32_MAX; time_t t = 67767976233532799; t_inspect(t-1); t_inspect(t); t_inspect(t+1); t_inspect(t+2); return 0; } The output on a 64 bit machine is (the interesting part is the sec=59) t: 67767976233532798, tp: 0x80085b9a0 errno: 2 sec: 58, min: 59, hour: 23, mday: 31, mon: 11, year: 2147481747, wday: 2, yday: 364, isdst: 0, gmtoff: 0, zone: UTC t: 67767976233532799, tp: 0x80085b9a0 errno: 0 sec: 59, min: 59, hour: 23, mday: 31, mon: 11, year: 2147481747, wday: 2, yday: 364, isdst: 0, gmtoff: 0, zone: UTC t: 67767976233532800, tp: 0x80085b9a0 errno: 0 sec: 59, min: 59, hour: 23, mday: 31, mon: 11, year: 2147481747, wday: 2, yday: 364, isdst: 0, gmtoff: 0, zone: UTC t: 67767976233532801, tp: 0x80085b9a0 errno: 0 sec: 59, min: 59, hour: 23, mday: 31, mon: 11, year: 2147481747, wday: 2, yday: 364, isdst: 0, gmtoff: 0, zone: UTC Right now, I am looking for confirmation from people on the list if this behaviour is also happening on other 64 bit operating systems or that it is a FreeBSD specific quirk. Edwin

On 12/05/10 04:54, Edwin Groothuis wrote:
Right now, I am looking for confirmation from people on the list if this behaviour is also happening on other 64 bit operating systems or that it is a FreeBSD specific quirk.
It doesn't happen on Fedora 12 (glibc-2.11.1-6) or RHEL4 (glibc-2.3.4-2.43.el4_8.3 which is quite old). Let me know if you'd like more information or different tests and I'll see what I can do. jch

I have tested on OpenSuSE 11.1. it seems the bug is fixed here. * Linux 2.6.27.42-0.1-default #1 SMP 2010-01-06 16:07:25 +0100 x86_64 x86_64 x86_64 GNU/Linux * gcc version 4.3.2 [gcc-4_3-branch revision 141291] (SUSE Linux) * GNU C Library stable release version 2.9 (20081117), by Roland McGrath et al. t: 67767976233532798, tp: 0x7fc6fc4e3de0 errno: 0 sec: 58, min: 59, hour: 23, mday: 31, mon: 11, year: 2147481747, wday: 2, yday: 364, isdst: 0, gmtoff: 0, zone: GMT t: 67767976233532799, tp: 0x7fc6fc4e3de0 errno: 0 sec: 59, min: 59, hour: 23, mday: 31, mon: 11, year: 2147481747, wday: 2, yday: 364, isdst: 0, gmtoff: 0, zone: GMT t: 67767976233532800, tp: 0x7fc6fc4e3de0 errno: 0 sec: 0, min: 0, hour: 0, mday: 1, mon: 0, year: 2147481748, wday: 3, yday: 0, isdst: 0, gmtoff: 0, zone: GMT t: 67767976233532801, tp: 0x7fc6fc4e3de0 errno: 0 sec: 1, min: 0, hour: 0, mday: 1, mon: 0, year: 2147481748, wday: 3, yday: 0, isdst: 0, gmtoff: 0, zone: GMT re, wh
The output on a 64 bit machine is (the interesting part is the sec=59)
t: 67767976233532798, tp: 0x80085b9a0 errno: 2 sec: 58, min: 59, hour: 23, mday: 31, mon: 11, year: 2147481747, wday: 2, yday: 364, isdst: 0, gmtoff: 0, zone: UTC t: 67767976233532799, tp: 0x80085b9a0 errno: 0 sec: 59, min: 59, hour: 23, mday: 31, mon: 11, year: 2147481747, wday: 2, yday: 364, isdst: 0, gmtoff: 0, zone: UTC t: 67767976233532800, tp: 0x80085b9a0 errno: 0 sec: 59, min: 59, hour: 23, mday: 31, mon: 11, year: 2147481747, wday: 2, yday: 364, isdst: 0, gmtoff: 0, zone: UTC t: 67767976233532801, tp: 0x80085b9a0 errno: 0 sec: 59, min: 59, hour: 23, mday: 31, mon: 11, year: 2147481747, wday: 2, yday: 364, isdst: 0, gmtoff: 0, zone: UTC
Right now, I am looking for confirmation from people on the list if this behaviour is also happening on other 64 bit operating systems or that it is a FreeBSD specific quirk.
Edwin
participants (3)
-
Edwin Groothuis
-
John Haxby
-
walter harms