[tz] localtime.c issue

Arthur David Olson arthurdavidolson at gmail.com
Mon Jul 8 20:44:19 UTC 2013


Looks as if the change below is what's needed; it is modeled on tzcode2013c.

(The 0.5 is only relevant on systems where time_t is some variety of
floating point; there may not be any such systems in the wild; the 0.5
should be optimized away by quality compilers on systems where time_t is
some variety of integer.)

    --ado

*** tzcode2013d/localtime.c    2013-05-28 00:26:18.000000000 -0400
--- tzcode2013e/localtime.c    2013-07-08 16:36:02.036867600 -0400
***************
*** 1514,1522 ****
      }
      {
          register int_fast32_t    seconds;
-         register time_t        half_second = 0.5;

!         seconds = tdays * SECSPERDAY + half_second;
          tdays = seconds / SECSPERDAY;
          rem += seconds - tdays * SECSPERDAY;
      }
--- 1514,1521 ----
      }
      {
          register int_fast32_t    seconds;

!         seconds = tdays * SECSPERDAY + 0.5;
          tdays = seconds / SECSPERDAY;
          rem += seconds - tdays * SECSPERDAY;
      }



On Mon, Jul 8, 2013 at 4:09 PM, Andy Heninger <aheninger at google.com> wrote:

> This compilation error from the localtime.c in 2013d looks like an actual
> problem. I think time_t is generally an integer type of some sort.
>
> Built using the clang compiler on Linux.
>
> localtime.c:1517:34: error: implicit conversion from 'double' to 'time_t'
> (aka 'long') changes value from 0.5 to 0 [-Werror,-Wliteral-conversion]
>                 register time_t         half_second = 0.5;
>                                         ~~~~~~~~~~~   ^~~
> 1 error generated.
>
> Thanks,
>   -- Andy Heninger
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mm.icann.org/pipermail/tz/attachments/20130708/26b6cdcd/attachment.htm>


More information about the tz mailing list