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.