bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gawk] gawk with dates before 1970


From: Glaudiston Gomes da Silva
Subject: Re: [bug-gawk] gawk with dates before 1970
Date: Tue, 14 Apr 2015 07:26:37 -0300

Andrew, Aharon and Eli,

Your comments are based on the first email's thread. After that I realize a better way that just comment and did another sugestion, to verify the type for signed/unsigned, and for unsigned, ok for fatal this, but if signed ignore this fatal:

https://lists.gnu.org/archive/html/bug-gawk/2015-04/msg00015.html

This way I think it keeps the current behavior to unsupported(unsigned) systems and improve this functionality to all signed systems.

thanks for the support.



2015-04-14 0:33 GMT-03:00 Andrew J. Schorr <address@hidden>:
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...

For example, using installed gawk with the old check in place:

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]