From owner-freebsd-bugs@FreeBSD.ORG Mon Nov 10 06:30:08 2008 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3BDA41065670 for ; Mon, 10 Nov 2008 06:30:08 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 209A38FC08 for ; Mon, 10 Nov 2008 06:30:08 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id mAA6U7tT007036 for ; Mon, 10 Nov 2008 06:30:08 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id mAA6U7Af007033; Mon, 10 Nov 2008 06:30:07 GMT (envelope-from gnats) Date: Mon, 10 Nov 2008 06:30:07 GMT Message-Id: <200811100630.mAA6U7Af007033@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Giorgos Keramidas Cc: Subject: Re: kern/128714: gmtime infinty loop X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Giorgos Keramidas List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Nov 2008 06:30:08 -0000 The following reply was made to PR kern/128714; it has been noted by GNATS. From: Giorgos Keramidas To: Vladimir Timfeev Cc: freebsd-gnats-submit@freebsd.org Subject: Re: kern/128714: gmtime infinty loop Date: Mon, 10 Nov 2008 08:21:32 +0200 On Sun, 9 Nov 2008 01:56:54 GMT, Vladimir Timfeev wrote: > On amd64 platforms (tested with 6.2 and 7.0). > gmtime from libc doesn't returns to program if called with > arg < -33884019326476800 > May be we should return NULL? > #include > #include > > void test(time_t t) { > struct tm *date; > printf("try %ld\n",t); > date = gmtime(&t); > printf(" ok\n"); > } > > int main(void) { > time_t time_ok = -33884019326476800LL; > time_t time_err = -33884019326476801LL; > test(time_ok); > test(time_err); > return 0; > } GCC warns about overflow when this is compiled with WARNS=6: foo.c:12: warning: overflow in implicit constant conversion foo.c:13: warning: overflow in implicit constant conversion Maybe that's part of the problem. On i386 it seems to work FWIW, but it does print bogus results (because of the implicit truncation that happens when a huge negative number is assigned to time_t -- which is equivalent to int32_t on i386): $ ./foo try -126116352 ok # Sun Jan 2 07:40:48 1966 try -126116353 ok # Sun Jan 2 07:40:47 1966