From: "Markus F.X.J. Oberhumer" Message-Id: <199610181233.NAA32624@osiris.oeh.uni-linz.ac.at> Subject: mktime() bug ? To: djgpp-workers AT delorie DOT com (djgpp-workers) Date: Fri, 18 Oct 1996 13:33:30 +0100 (MET) Return-read-to: mfx AT oeh DOT uni-linz DOT ac DOT at Content-Type: text Content-Length: 1817 =============================================================================== Markus F.X.J. Oberhumer Subject: mktime() bug ? To: djgpp-workers AT delorie DOT com =============================================================================== Some time ago I found a really annoying bug in mktime(). I encountered it in stat() where it caused 'make' think that a file doesn't exist. The bug prevented me to rebuild libc.a because out of the hundreds of files in src/libc about 10 files had a timestamp that made mktime() fail. Could someone please check if the following program works fine with the latest snapshot ? /*********************************************************************** // mktime fails on rare occasions ************************************************************************/ #include #include #include #include int main(int argc, char *argv[]) { struct tm tmm; time_t t; const char *tz; /* the April 1995 bug can be reproduced with (at least) these timezones: */ putenv("TZ=MET-1MEST"); // putenv("TZ=e:/l/djgpp2/zoneinfo/met"); // putenv("TZ=e:/l/djgpp2/zoneinfo/gmt-1"); tzset(); memset(&tmm, 0, sizeof(struct tm)); tmm.tm_isdst = -1; /* let mktime() determine if DST is in effect */ tmm.tm_sec = 40; tmm.tm_min = 22; tmm.tm_hour = 2; tmm.tm_mday = 2; tmm.tm_year = 1995 - 1900; /* 0 = January */ tmm.tm_mon = 5 - 1; /* May - this works with all timezones */ tmm.tm_mon = 4 - 1; /* April - !!! this fails !!! */ t = mktime(&tmm); if (t == (time_t) -1) printf("error !\n"); else printf("%s",ctime(&t)); tz = getenv("TZ"); printf("TZ=%s\n", tz == NULL ? "" : tz); return 0; }