[tz] [PROPOSED] Fix unlikely conversion bug in zic

Jonathan Leffler jonathan.leffler at gmail.com
Sat Nov 5 03:17:16 UTC 2022


It's not relevant yet, but the C23 standard requires 2's-complement
arithmetic.

In document N2912 (available from the committee website
https://open-std.org/jtc1/sc22/wg14/ under 'documents'), which is the June
2022 draft of the standard, section 6.2.6.2 Integer types says:

NOTE 2 The sign representation defined in this document is called two’s
> complement. Previous revisions of this document additionally allowed
> other sign representations.


So, in a decade or two, we will be able to ignore systems which do not use
2's-complement arithmetic.  If you were ruthless, you could probably ignore
1's-complement and sign-magnitude systems now — this is very largely
recognizing the status quo.  There probably are a few mainframe antiques
around with the alternatives, but not many.


On Fri, Nov 4, 2022 at 9:01 PM Paul Eggert via tz <tz at iana.org> wrote:

> * zic.c (puttzcode): Arg is zic_t, not int_fast32_t.  This fixes a
> portability bug on platforms where int_fast32_t is a 32-bit ones’
> complement or signed-magnitude integer, and where the argument is
> -2**31 before conversion to int_fast32_t.  Although I don’t know
> of any such platforms, the C standard allows them.
> ---
>

-- 
Jonathan Leffler <jonathan.leffler at gmail.com>  #include <disclaimer.h>
Guardian of DBD::Informix - v2018.1031 - http://dbi.perl.org
"Blessed are we who can laugh at ourselves, for we shall never cease to be
amused."
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mm.icann.org/pipermail/tz/attachments/20221104/08569543/attachment.html>


More information about the tz mailing list