summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>2015-11-18 16:54:16 +0000
committerlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>2015-11-18 16:54:16 +0000
commit572d92c423f86305bc0e22573e88428f8b8a7aff (patch)
tree67f5942c399a0a5b7626c88dfa86d3940e8c9eaa
parent4a9e926a1d442915e607c9cb9c113eced8eba8e9 (diff)
downloadgcc-572d92c423f86305bc0e22573e88428f8b8a7aff.tar.gz
* gcc.dg/tree-ssa/split-path-1.c: Fix the testcase
to avoid undefined behaviour. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@230555 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/split-path-1.c16
2 files changed, 14 insertions, 7 deletions
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 <ajitkum@xilinx.com>
+
+ * gcc.dg/tree-ssa/split-path-1.c: Fix the testcase
+ to avoid undefined behaviour.
+
2015-11-18 Jakub Jelinek <jakub@redhat.com>
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 <stdio.h>
#include <stdlib.h>
+#include <ctype.h>
-#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;