Re: [RFC 1/2] compiler: use compiler to detect integer overflows

From: Dan Carpenter
Date: Fri Dec 05 2014 - 14:39:15 EST


On Fri, Dec 05, 2014 at 10:50:19AM -0800, Linus Torvalds wrote:
> On Fri, Dec 5, 2014 at 1:54 AM, Dan Carpenter <dan.carpenter@xxxxxxxxxx> wrote:
> >
> > There are some false positives which do:
> >
> > if ((u16)(u16_foo + u16_bar) < u16_foo) {
>
> Actually, the worse false positive is the ones that are pointer comparisons.
>
> A compiler that does those as signed is just broken. It's happened,
> but it's *still* completely broken.
>

Oh. Wow... That's embarrassing. I thought they were signed for some
reason, and I thought it was weird, but I didn't think about it hard
enough...

I'll redo this.

regards,
dan carpenter
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/