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


View this message in rfc822 format

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Rich Felker <dalias <at> aerifal.cx>
Cc: 7928 <at> debbugs.gnu.org, bug-gnulib <bug-gnulib <at> gnu.org>, Eric Blake <eblake <at> redhat.com>
Subject: bug#7928: mktime test in configure: UB resulting in infinite loop
Date: Thu, 27 Jan 2011 09:57:06 -0800
On 01/27/11 09:28, Rich Felker wrote:
> On Thu, Jan 27, 2011 at 08:14:56AM -0700, Eric Blake wrote:
>> > # define TYPE_MINIMUM(t) \
>> >   ((t) (! TYPE_SIGNED (t) \
>> >         ? (t) 0 \
>> >         : TYPE_SIGNED_MAGNITUDE (t) \
>> >         ? ~ (t) 0 \
>> >         : ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1)))
>> > # define TYPE_MAXIMUM(t) \
>> >   ((t) (! TYPE_SIGNED (t) \
>> >         ? (t) -1 \
>> >         : ~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))))
> The last line of this macro has UB due to signed integer overflow in
> the << operation.

No it doesn't.  ~ (t) 0 evaluates to -1, and -1 << 31 does not
overflow.




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.