Re: [PATCH] do not depend on undefined signed integer overflow

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

 



On Mon, Oct 4, 2010 at 9:43 PM, Erik Faye-Lund <kusmabite@xxxxxxxxx> wrote:
> +/*
> + * Signed integer overflow is undefined in C and some compilers take
> + * advantage of this when optimizing, so here's a helper macro to force
> + * wrapping when adding two integers. The size to wrap to is taken from
> + * the first parameter.
> + */
> +#define signed_add_overflows(a, b) \
> +    ((b) > ((INTMAX_MAX >> (bitsizeof(uintmax_t) - bitsizeof(a))) - (a)))
> +

*Sigh*, I already see that this comment is out of date (I did a
different approach before this one). Sorry, I will fix up this comment
for the next round.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]