From 3c72bf3495671dc8d9d4c2b075a265f2f72908ae Mon Sep 17 00:00:00 2001 From: Rask Ingemann Lambertsen Date: Wed, 25 Jul 2007 13:13:41 +0200 Subject: [PATCH] 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 --- gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/gcc.dg/tree-ssa/predcom-1.c | 2 +- gcc/testsuite/gcc.dg/tree-ssa/predcom-2.c | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 057c0ca873c..d7ab831b934 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2007-07-25 Rask Ingemann Lambertsen + + * 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 * gcc.dg/torture/pr29584.c: Only run test if pointers have the same diff --git a/gcc/testsuite/gcc.dg/tree-ssa/predcom-1.c b/gcc/testsuite/gcc.dg/tree-ssa/predcom-1.c index 8e6e897199d..584f9eb0231 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/predcom-1.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/predcom-1.c @@ -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) diff --git a/gcc/testsuite/gcc.dg/tree-ssa/predcom-2.c b/gcc/testsuite/gcc.dg/tree-ssa/predcom-2.c index b7088c5f83f..3ad13eaeda0 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/predcom-2.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/predcom-2.c @@ -4,7 +4,7 @@ void abort (void); -int fib[1000]; +long int fib[1000]; void count_fib(void) {