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: Rich Felker <dalias <at> aerifal.cx>
To: Bruno Haible <bruno <at> clisp.org>
Cc: bug-gnulib <at> gnu.org, Paul Eggert <eggert <at> cs.ucla.edu>, 7928 <at> debbugs.gnu.org, Eric Blake <eblake <at> redhat.com>
Subject: bug#7928: mktime test in configure: UB resulting in infinite loop
Date: Fri, 28 Jan 2011 14:13:59 -0500
On Fri, Jan 28, 2011 at 06:57:22PM +0100, Bruno Haible wrote:
> Rich Felker wrote:
> > Testing which of the three allowable signed integer
> > representations is used is easy: compare ~(t)1 against and -(t)1 and
> > -(t)2.
> 
> Testing which of the three signed integer representations is in use
> is not even needed: Your formula
>   ((((t) 1 << (sizeof (t) * CHAR_BIT - 2)) - 1) * 2 + 1)
> yields the correct result in all three cases.

It yields the correct max. However, getting the min requires knowing
whether min is -max or -max-1. This depends on which of the
representations is used:

min = ~(t)1 == -(t)2 ? -max-1 : -max;

Rich




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.