summaryrefslogtreecommitdiff
path: root/time64.c
diff options
context:
space:
mode:
authorMichael G Schwern <schwern@pobox.com>2010-01-31 02:53:43 -0800
committerH.Merijn Brand <h.m.brand@xs4all.nl>2010-01-31 12:46:14 +0100
commit455f2c6c92e42c1a9e31268cbd491ba661f99882 (patch)
tree67c43ffb262f4158b0744b1af2818436ad43030e /time64.c
parentb224edc1e71fa31c9529c6a3951b807564b5d78a (diff)
downloadperl-455f2c6c92e42c1a9e31268cbd491ba661f99882.tar.gz
gmtime/localtime are busted around 2**48
Michael G Schwern wrote: > Anyhow, I'm willing to let that drop, but I want figure out A) why its > failing so early because it might be masking a bug, this is not > predicted behavior, and most importantly B) to get it to error, or at > least warn. > > I know B is possible, I did it for Time::y2038. I'll figure that part > out and try to dig into A. I would like to call B a blocker for 5.12. Found the bug, patch attached. v_tm_tday is an NV, so casting time to an integer will cause an overflow 2**31 days after 1970 or somewhere between 2**47 and 2**48. Not sure why the compiler didn't warn about that. This makes it work until the year overflows. As for putting in a warning, there's two options: 1) A few days before the 32 bit year overflows. 2) At some reasonable point before there's too much floating point inaccuracy. The possibility of long doubles will make #2 difficult to nail down, but I'll be happy with +/- 2**53. -- 24. Must not tell any officer that I am smarter than they are, especially if it's true. -- The 213 Things Skippy Is No Longer Allowed To Do In The U.S. Army http://skippyslist.com/list/ From 9e940e610ac5b2fbb09a554f505963094a4a0745 Mon Sep 17 00:00:00 2001 From: Michael G. Schwern <schwern@pobox.com> Date: Sun, 31 Jan 2010 02:24:50 -0800 Subject: [PATCH] Type conversion bug in gmtime64 that was causing it to crap out around 2**48 Signed-off-by: H.Merijn Brand <h.m.brand@xs4all.nl>
Diffstat (limited to 'time64.c')
-rw-r--r--time64.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/time64.c b/time64.c
index ca31acf0ad..1d43f39717 100644
--- a/time64.c
+++ b/time64.c
@@ -377,7 +377,7 @@ static struct TM *S_gmtime64_r (const Time64_T *in_time, struct TM *p)
time = time >= 0 ? floor(time / 60.0) : ceil(time / 60.0);
v_tm_hour = (int)fmod(time, 24.0);
time = time >= 0 ? floor(time / 24.0) : ceil(time / 24.0);
- v_tm_tday = (int)time;
+ v_tm_tday = time;
WRAP (v_tm_sec, v_tm_min, 60);
WRAP (v_tm_min, v_tm_hour, 60);