GNU bug report logs -
#7928
mktime test in configure: UB resulting in infinite loop
Previous Next
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
On Thu, Jan 27, 2011 at 11:42:25PM -0800, Paul Eggert wrote:
> On 01/27/2011 02:08 PM, Rich Felker wrote:
> > I mean to say that left-shifting a negative value *at all* is
> > undefined behavior. I doubt gcc will ever break it, but why not use my
> > version of the code that's 100% safe and never invokes undefined
> > behavior?
>
> Your version of the code provokes similar undefined behavior
> when computing TYPE_MINIMUM, which means that overall it's
> no more reliable than what's there now. An advantage of
> the current approach is that there's a clear relationship
> between TYPE_MINIMUM and TYPE_MAXIMUM, and this aids understanding.
> If it could be done just as clearly by other means, that would
> be OK too.
My version only computes the maximum. The minimum is -max if the type
is sign/magnitude or ones complement and -max-1 if the type is twos
complement. Testing which of the three allowable signed integer
representations is used is easy: compare ~(t)1 against and -(t)1 and
-(t)2.
Rich
This bug report was last modified 14 years and 176 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.