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.