Re: Efficient detection of signed overflow?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2009/11/29 Mark Dickinson <dickinsm@xxxxxxxxx>:
>
> This code is wrong, I think, because it depends on undefined
> behaviour.  I'm wondering how best to rewrite it so that (a)
> the replacement code is correct and portable C89, and (b)
> there's a reasonable chance of gcc compiling it to efficient
> assembler on common platforms.
>

What about using (long)((unsigned long)a + (unsigned long)b) or
something to get around the UB?


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux