Compiling with the option -Wshift-negative-value outputs the following warning:
missing_d/mktime.c:82:22: warning: left shift of negative value [-Wshift-negative-value]
: ~ (time_t) 0 << (sizeof (time_t) * CHAR_BIT - 1))
In relation to gcc PR c/65179, Martin Sebor wrote:
"Shifting a negative value by a positive number of bits does have a natural meaning (i.e., shifting the bit pattern the same way as unsigned). The reason why it's undefined in C and C++ is because some processors don't shift the sign bit out and may raise an overflow when a one bit is shifted into the sign position (typically those that provide an arithmetic left shift). But most processors implement a logical left shift and behave the same way for signed operands as for unsigned. The result of a left shift of a negative number computed by GCC matches that of hardware that doesn't differentiate between arithmetic and logical left shifts (which is all the common CPUs, including ARM, MIPS, PowerPC, x86), so the only value in diagnosing it is portability to rare CPUs or to compilers that behave differently than GCC (if there are any)."
On most platforms, the attached patch does not provide any functional change.
Besides, do you think using intmax_t and uintmax_t could results in a portability loss ?