[tz] localtime.c patch

Clive D.W. Feather clive at davros.org
Wed Oct 8 07:00:37 UTC 2014

Paul Eggert said:
> Although C99-and-later guarantees that memset(..., 0, ...) sets the struct 
> ttinfo members (which are int, bool, and int_fast32_t) to zero, tzcode assumes 
> only C89 which as I understand it does not provide that guarantee, so to be safe 
> we should avoid memset here.

No. I can't track it down right now, but the view of WG14 was always that
the representations of types stuff added in C99 was intended to have always
applied to C90 as well. See Defect Report 069 for some stuff on this as

> However, POSIX weirdly says that ssize_t might not be able to store values 
> less than -1,

Huh? POSIX is built on C, and C doesn't have any type which is signed but
with a minimum of greater than -127. I can see that POSIX says "The type
ssize_t shall be capable of storing values at least in the range [-1,
{SSIZE_MAX}].", but that doesn't exempt it from the C rules concerning
types. If the maximum value of ssize_t is (say) 8191, then the minimum is
either -8191 or -8192.

> which means subtracting a value from ssize_t is a no-no if the 
> result might be less than -1, which means we need to redo a subtraction that 
> might compute such a result.

Not so.

Clive D.W. Feather          | If you lie to the compiler,
Email: clive at davros.org     | it will get its revenge.
Web: http://www.davros.org  |   - Henry Spencer
Mobile: +44 7973 377646

More information about the tz mailing list