GNU bug report logs - #7928
mktime test in configure: UB resulting in infinite loop

Previous Next

Package: coreutils;

Reported by: Rich Felker <dalias <at> aerifal.cx>

Date: Thu, 27 Jan 2011 06:44:02 UTC

Severity: normal

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


Message #20 received at 7928 <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Eric Blake <eblake <at> redhat.com>
Cc: 7928 <at> debbugs.gnu.org, bug-gnulib <bug-gnulib <at> gnu.org>,
	Rich Felker <dalias <at> aerifal.cx>
Subject: Re: bug#7928: mktime test in configure: UB resulting in infinite loop
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.




This bug report was last modified 14 years and 177 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.