Date: Mon, 10 Nov 2008 06:30:07 GMT From: Giorgos Keramidas <keramida@freebsd.org> To: freebsd-bugs@FreeBSD.org Subject: Re: kern/128714: gmtime infinty loop Message-ID: <200811100630.mAA6U7Af007033@freefall.freebsd.org>
index | next in thread | raw e-mail
The following reply was made to PR kern/128714; it has been noted by GNATS.
From: Giorgos Keramidas <keramida@freebsd.org>
To: Vladimir Timfeev <vovkasm@gmail.com>
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 <vovkasm@gmail.com> 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 <time.h>
> #include <stdio.h>
>
> 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
home |
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200811100630.mAA6U7Af007033>
