[Bug 221418] FreeBSD 10.4-PRERELEASE fails to build on systems using 32 bit time_t since r322315.
Bruce Evans
brde at optusnet.com.au
Sat Aug 12 10:59:34 UTC 2017
On Fri, 11 Aug 2017 a bug that doesn't want replies at freebsd.org wrote:
> --- Comment #1 from Conrad Meyer <cem at freebsd.org> ---
> Truncated INT64_MIN should be INT32_MIN on 2's complement, not 0. Seems like
> we just lack a (time_t) cast on the value.
Truncated INT64_MIN should be and is, 0 in 2's complement, since all of
its low 32 bits are 0. In 1's complement, it should be -0, since all
of its low 32 bits are 1.
Casting to time_t is no different to assigning to time_t, except compilers
usually only warn about overflow for the assignent. Casting thus enlarges
the bug by breaking the warning about overflow.
Related to this, the special value for possibly-invalid time_t's is
((time_t)-1), not some large negative value. This is large and positive
if time_t is unsigned. In POSIX, times before the Epoch are invalid, but
(time_t)-1) might be valid if it is positive. In Standard C, (time_t)-1)
might be valid even if it is -1.
I think the code needs a large negative value for technical reasons.
INT64_MIN is very bogus for this, since 69 years in the past given by
INT32_MIN should be enough for anyone, and further in the past than
that is unrepresentable by time_t on systems with 32-bit signed time_t.
If time_t is unsigned, no negative values are representable, so casts
to int but not to time_t might be needed.
> With regards to your patch, CHAR_BIT is always 8 on FreeBSD.
CHAR_BIT is 8 on all POSIX systems later than 2001.
CHAR_BIT is often spelled NBBY in BSD. NBBY is less verbose than CHAR_BIT
and less cryptic than 8.
Bruce
More information about the freebsd-bugs
mailing list