bug-binutils
[Top][All Lists]
Advanced

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

Re: Fix undefined shift overflow


From: Michael McConville
Subject: Re: Fix undefined shift overflow
Date: Mon, 1 Feb 2016 11:22:46 -0500

Nick Clifton wrote:
> > Shifting into and out of the sign bit of an integer is undefined,
> > and this loop unconditionally does both. The below patch should fix
> > it.
> 
> Patch approved and applied.  Thanks for reporting this.

Thanks!

This idiom also appears in newlib and in various versions of GDB and
associated codebases. I'm not sure how this maps to actual development
repos. All forms I found are one of the following source text snippets:

> (m = 1; m != 0; m <<= 1)

> (i = 1; i; i <<= 1)

If you grep for that, you may find more. Of course, it's only a bug if
the variable is signed. If you're getting annoying false positives, I'm
happy to help with Coccinelle. That's what I used to find these.

Best,
Michael



reply via email to

[Prev in Thread] Current Thread [Next in Thread]