From: Ajit Agarwal Date: Wed, 18 Nov 2015 16:54:16 +0000 (+0000) Subject: split-path-1.c: Fix the testcase to avoid undefined behaviour. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3927713bcf7a7f2e91fbfa3b324a1fbb71aa1364;p=gcc.git split-path-1.c: Fix the testcase to avoid undefined behaviour. * gcc.dg/tree-ssa/split-path-1.c: Fix the testcase to avoid undefined behaviour. From-SVN: r230555 --- diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 08f910427ac..50e410cc9ea 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-11-18 Ajit Agarwal + + * gcc.dg/tree-ssa/split-path-1.c: Fix the testcase + to avoid undefined behaviour. + 2015-11-18 Jakub Jelinek PR tree-optimization/68157 diff --git a/gcc/testsuite/gcc.dg/tree-ssa/split-path-1.c b/gcc/testsuite/gcc.dg/tree-ssa/split-path-1.c index 12398924dba..5c96241aa0c 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/split-path-1.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/split-path-1.c @@ -3,16 +3,17 @@ #include #include +#include -#define RGBMAX 255 +#define RGBMAX 255 -int +unsigned char test() { int i, Pels; - unsigned char sum = 0; + int sum = 0; unsigned char xr, xg, xb; - unsigned char xc, xm, xy, xk; + unsigned char xc, xm, xy, xk = 0; unsigned char *ReadPtr, *EritePtr; ReadPtr = ( unsigned char *) malloc (sizeof (unsigned char) * 100); @@ -23,7 +24,7 @@ test() ReadPtr[i] = 100 - i; } - for (i = 0; i < 100; i++) + for (i = 0; i < 24; i++) { xr = *ReadPtr++; xg = *ReadPtr++; @@ -50,7 +51,8 @@ test() *EritePtr++ = xm; *EritePtr++ = xy; *EritePtr++ = xk; - sum += *EritePtr; + sum += *(--EritePtr); + } return sum; } @@ -58,7 +60,7 @@ test() int main() { - if (test() != 33) + if (test() != 196) abort(); return 0;