This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFA: Fix sim scache handling to use unsigned values.


On 03 Feb 2016 16:25, Nick Clifton wrote:
>   A recent bug report on the binutils list pointed out that a construct
>   like this:
> 
>    for (i = 1; i; i <<= 1)
> 
>   can have undefined behaviour if the loop variable is signed and the
>   shift operation moves a 1 into the sign bit:
> 
>     lists.gnu.org/archive/html/bug-binutils/2016-02/msg00006.html
> 
>   A quick scan of the simulator sources found one place where this
>   happens, in common/cgen-scache.c:scache_option_handler().  Looking at
>   the code here it seemed to me that the simplest fix is to switch to
>   using an unsigned int for the parsed value of the scache size.  (A
>   negative scache size does not make any sense right ?)  I wondered if
>   it would be worth using "unsigned long" instead of "unsigned int",
>   since there is no strtou() function, but this seemed like overkill.
> 
>   So I created the patch below.  It builds OK, but I am not sure how to
>   test it.  Any suggestions ?

seems fine
-mike

Attachment: signature.asc
Description: Digital signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]