1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18#include <stdio.h>
19
20int gA[401];
21int gB[401];
22int gC[401];
23
24void vector_add_int()
25{
26 int i;
27 for (i = 0; i < 400; i++) {
28 gA[i] = gB[i] + gC[i];
29 }
30}
31
32int main()
33{
34 int error = 0;
35 int i;
36 for (i = 0; i < 400; i++) {
37 gB[i] = i * 2;
38 gC[i] = i * 3;
39 }
40 gA[400] = 17;
41 vector_add_int();
42 for (i = 0; i < 400; i++) {
43 if (gA[i] != i * 5) {
44 error++;
45 printf("ERROR: gB[%d] = %d\t", i, gB[i]);
46 printf("gC[%d] = %d\t", i, gC[i]);
47 printf("gA[%d] = %d\n", i, gA[i]);
48 }
49 }
50 if (gA[400] != 17) {
51 error++;
52 printf("ERROR: Overran the buffer\n");
53 }
54 if (!error) {
55 printf("PASS\n");
56 return 0;
57 } else {
58 printf("FAIL\n");
59 return 1;
60 }
61}
62