This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH 4/5][testsuite] Fix overflows with 16-bit int
- From: Janis Johnson <janis187 at us dot ibm dot com>
- To: Rask Ingemann Lambertsen <rask at sygehus dot dk>
- Cc: gcc-patches at gcc dot gnu dot org, rakdver at gcc dot gnu dot org
- Date: Tue, 24 Jul 2007 14:21:18 -0700
- Subject: Re: [PATCH 4/5][testsuite] Fix overflows with 16-bit int
- References: <20070724160434.GB4125@sygehus.dk> <20070724171338.GF4125@sygehus.dk>
- Reply-to: janis187 at us dot ibm dot com
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