|
From: | Glaudiston Gomes da Silva |
Subject: | Re: [bug-gawk] gawk with dates before 1970 |
Date: | Tue, 14 Apr 2015 07:26:37 -0300 |
For example, using installed gawk with the old check in place:On Mon, Apr 13, 2015 at 11:06:39PM -0400, Andrew J. Schorr wrote:
> On Mon, Apr 13, 2015 at 04:30:03PM +0300, Aharon Robbins wrote:
> > > You cannot just delete those lines, because some systems have time_t
> > > as an unsigned data type.
> >
> > The actual variable used is a long, in order to be able to
> > test for < 0. But removing them doesn't seem to cause any
> > problems.
>
> I may be confused, but I think Eli's point was that time_t could be unsigned,
> so when the code says:
>
> time_t fclock;
> long clock_val;
>
> clock_val = <value of 2nd argument>
> fclock = (time_t) clock_val;
>
> the value could be changed. In that case, strftime would give an unexpected
> result. In general, we're stuffing a double-precision or MPFR value
> into a time_t. Should we check after the conversion that we haven't
> mutilated the value? Either of those assignments could alter the value...
bash-4.2$ /bin/gawk 'BEGIN {print strftime("%F-%T", 1e300)}'
gawk: cmd. line:1: fatal: strftime: second argument less than 0 or too big for time_t
With the new code in the master branch:
bash-4.2$ ./gawk 'BEGIN {print strftime("%F-%T", 1e300)}'
gawk: cmd. line:1: fatal error: internal error
Aborted (core dumped)
In the debugger, I see:
(gdb) print fclock
$1 = -9223372036854775808
This behavior seems a bit unattractive. :-)
Regards,
Andy
[Prev in Thread] | Current Thread | [Next in Thread] |