bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Paul Eggert
Subject: Re: bug#7928: mktime test in configure: UB resulting in infinite loop
Date: Thu, 27 Jan 2011 10:25:03 -0800
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101208 Thunderbird/3.1.7

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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]