This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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: [PATCH 4/5][testsuite] Fix overflows with 16-bit int


On Tue, 2007-07-24 at 19:13 +0200, Rask Ingemann Lambertsen wrote:
>    With a 16-bit int, the first of these two tests cause an overflow during
> addition, resulting in an execution failure. By casting to "unsigned long",
> the overflow is avoided.
> 
>    The second testcase will overflow already when setting up the fib array:
> 
>     fib[i] = (fib[i-1] + fib[i - 2]) & 0xffff;
> 
> Clamping to 0xffff doesn't help when the maximum fib[i] can hold is 0x7ffff,
> so the execution test fails. It is fixed by using a longer, signed integer.
> 
>    Ok for trunk?
> 
> :ADDPATCH testsuite:
> 
> 2007-07-24  Rask Ingemann Lambertsen  <rask@sygehus.dk>
> 
> 	* gcc.dg/tree-ssa/predcom-1.c (count_averages): Avoid overflow
> 	  during addition if an int is only 16 bits wide.
> 	* gcc.dg/tree-ssa/predcom-2.c (fib): Avoid overflow of 16-bit int.

:REVIEWMAIL:

OK.

Janis


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