2009/11/30 Florian Weimer <fw@xxxxxxxxxxxxx>: > >> On Sun, Nov 29, 2009 at 9:00 PM, me22 <me22.ca@xxxxxxxxx> wrote: >>> What about using (long)((unsigned long)a + (unsigned long)b) or >>> something to get around the UB? > > You'd also have to compare against (1 << (sizeof(long) * CHAR_BITS - > 1)) instead of 0, pessimizing the code somewhat. > Why? If numbers are 2s-complement, the cast back to a signed type is well-defined, isn't it?