On Fri, 11 Aug 2017 a bug that doesn't want repl...@freebsd.org wrote:
--- Comment #1 from Conrad Meyer <c...@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 _______________________________________________ freebsd-bugs@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/freebsd-bugs To unsubscribe, send any mail to "freebsd-bugs-unsubscr...@freebsd.org"