predcom-1.c (count_averages): Avoid overflow during addition if an int is only 16 bits wide.

* 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.

From-SVN: r126908
This commit is contained in:
Rask Ingemann Lambertsen 2007-07-25 13:13:41 +02:00 committed by Rask Ingemann Lambertsen
parent ba6cb9d268
commit 3c72bf3495
3 changed files with 8 additions and 2 deletions

View File

@ -1,3 +1,9 @@
2007-07-25 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.
2007-07-25 Rask Ingemann Lambertsen <rask@sygehus.dk>
* gcc.dg/torture/pr29584.c: Only run test if pointers have the same

View File

@ -23,7 +23,7 @@ void count_averages(int n)
int i;
for (i = 1; i < n; i++)
avg[i] = ((fib[i - 1] + fib[i] + fib[i + 1]) / 3) & 0xffff;
avg[i] = (((unsigned long) fib[i - 1] + fib[i] + fib[i + 1]) / 3) & 0xffff;
}
int main(void)

View File

@ -4,7 +4,7 @@
void abort (void);
int fib[1000];
long int fib[1000];
void count_fib(void)
{