FW: tzcode2006a.tar.gz on Irix 6.5.18m
Paul Eggert
eggert at CS.UCLA.EDU
Wed Feb 8 00:37:00 UTC 2006
Thanks for looking into the problem. zdump.c relies on undefined
behavior on overflow, which is the problem here, but if we can assume
C99+LIA-1 semantics (the common case) we can get a reliable result.
Also, I think it's safer to avoid 'register'.
Does the following patch to zdump.c fix things for you?
--- zdump.c 2006/02/02 20:42:22 2005.18.0.1
+++ zdump.c 2006/02/08 00:33:28
@@ -418,14 +418,21 @@ _("%s: use of -v on system with floating
}
} else if (0 > (time_t) -1) {
/*
- ** time_t is signed.
+ ** time_t is signed. Assume overflow wraps around.
*/
- register time_t hibit;
+ time_t t = 0;
+ time_t t1 = 1;
- for (hibit = 1; (hibit * 2) != 0; hibit *= 2)
- continue;
- absolute_min_time = hibit;
- absolute_max_time = -(hibit + 1);
+ while (t < t1) {
+ t = t1;
+ t1 = 2 * t1 + 1;
+ }
+
+ absolute_max_time = t;
+ t = -t;
+ absolute_min_time = t - 1;
+ if (t < absolute_min_time)
+ absolute_min_time = t;
} else {
/*
** time_t is unsigned.
More information about the tz
mailing list