Subject: Re: bug#7928: mktime test in configure: UB resulting in infinite loop

From: Paul Eggert <[email-masked]>
Date: Thu, 27 Jan 2011 10:25:03 -0800

On 01/27/11 10:15, Eric Blake wrote:
> In other words, the problem is not about overflow, but about undefined
> behavior.

You're right that the behavior is not defined, but this should
not be a problem in practice, any more than the * CHAR_BIT business
should be a problem in practice (that also relies a not-guaranteed-
by-the-standard assumption).

Currently the code assumes that if time_t values are signed,
then they use either two's complement, ones' complement,
or signed magnitude representation internally, that left shift
shifts those bits left, and that there are no padding bits.  The
assumptions about left-shift and no padding bits are not guaranteed
by the C standard, but they are portable in practice, even when using
the latest GCC with all the optimization bells and whistles enabled.

It's unlikely that GCC will ever break expressions
like -1 << 1 merely because the C standard lets it do that.