1 /* { dg-do run } */
2 /* { dg-options "-O2" } */
3
4 #include <string.h>
5 #include <stdlib.h>
6
7 #define LEN (100)
8 short a[LEN];
9 int b[LEN];
10
11 void
init(signed char * arr,int len)12 init (signed char *arr, int len)
13 {
14 int i;
15 for (i = 0; i < len; i++)
16 arr[i] = 0;
17 }
18
19 void
check(signed char * arr,int idx,int len,int v)20 check (signed char *arr, int idx, int len, int v)
21 {
22 int i;
23 for (i = 0; i < idx; i++)
24 if (arr[i] != v)
25 abort ();
26
27 for (i = idx; i < len; i++)
28 if (arr[i] != 0)
29 abort ();
30 }
31
32 #define TEST(a,l,v) \
33 init ((signed char*)(a), sizeof (a)); \
34 memset ((a), (v), (l)); \
35 check ((signed char *)(a), (l), sizeof (a), (v));
36 int
main(void)37 main(void)
38 {
39 TEST (a, 1, -1);
40 TEST (a, 2, -1);
41 TEST (a, 3, -1);
42 TEST (a, 4, -1);
43 TEST (a, 5, -1);
44 TEST (a, 6, -1);
45 TEST (a, 7, -1);
46 TEST (a, 8, -1);
47 TEST (a, 9, 1);
48 TEST (a, 10, -1);
49 TEST (a, 11, 1);
50 TEST (a, 12, -1);
51 TEST (a, 13, 1);
52 TEST (a, 14, -1);
53 TEST (a, 15, 1);
54 TEST (a, 16, -1);
55 TEST (a, 17, 1);
56 TEST (a, 18, -1);
57 TEST (a, 19, 1);
58 TEST (a, 20, -1);
59 TEST (a, 21, 1);
60 TEST (a, 22, -1);
61 TEST (a, 23, 1);
62 TEST (a, 24, -1);
63 TEST (a, 25, 1);
64 TEST (a, 26, -1);
65 TEST (a, 27, 1);
66 TEST (a, 28, -1);
67 TEST (a, 29, 1);
68 TEST (a, 30, -1);
69 TEST (a, 31, 1);
70 TEST (a, 32, -1);
71 TEST (a, 33, 1);
72 TEST (a, 34, -1);
73 TEST (a, 35, 1);
74 TEST (a, 36, -1);
75 TEST (a, 37, 1);
76 TEST (a, 38, -1);
77 TEST (a, 39, 1);
78 TEST (a, 40, -1);
79 TEST (a, 41, 1);
80 TEST (a, 42, -1);
81 TEST (a, 43, 1);
82 TEST (a, 44, -1);
83 TEST (a, 45, 1);
84 TEST (a, 46, -1);
85 TEST (a, 47, 1);
86 TEST (a, 48, -1);
87 TEST (a, 49, 1);
88 TEST (a, 50, -1);
89 TEST (a, 51, 1);
90 TEST (a, 52, -1);
91 TEST (a, 53, 1);
92 TEST (a, 54, -1);
93 TEST (a, 55, 1);
94 TEST (a, 56, -1);
95 TEST (a, 57, 1);
96 TEST (a, 58, -1);
97 TEST (a, 59, 1);
98 TEST (a, 60, -1);
99 TEST (a, 61, 1);
100 TEST (a, 62, -1);
101 TEST (a, 63, 1);
102 TEST (a, 64, -1);
103
104 TEST (b, 1, -1);
105 TEST (b, 2, -1);
106 TEST (b, 3, -1);
107 TEST (b, 4, -1);
108 TEST (b, 5, -1);
109 TEST (b, 6, -1);
110 TEST (b, 7, -1);
111 TEST (b, 8, -1);
112 TEST (b, 9, 1);
113 TEST (b, 10, -1);
114 TEST (b, 11, 1);
115 TEST (b, 12, -1);
116 TEST (b, 13, 1);
117 TEST (b, 14, -1);
118 TEST (b, 15, 1);
119 TEST (b, 16, -1);
120 TEST (b, 17, 1);
121 TEST (b, 18, -1);
122 TEST (b, 19, 1);
123 TEST (b, 20, -1);
124 TEST (b, 21, 1);
125 TEST (b, 22, -1);
126 TEST (b, 23, 1);
127 TEST (b, 24, -1);
128 TEST (b, 25, 1);
129 TEST (b, 26, -1);
130 TEST (b, 27, 1);
131 TEST (b, 28, -1);
132 TEST (b, 29, 1);
133 TEST (b, 30, -1);
134 TEST (b, 31, 1);
135 TEST (b, 32, -1);
136 TEST (b, 33, 1);
137 TEST (b, 34, -1);
138 TEST (b, 35, 1);
139 TEST (b, 36, -1);
140 TEST (b, 37, 1);
141 TEST (b, 38, -1);
142 TEST (b, 39, 1);
143 TEST (b, 40, -1);
144 TEST (b, 41, 1);
145 TEST (b, 42, -1);
146 TEST (b, 43, 1);
147 TEST (b, 44, -1);
148 TEST (b, 45, 1);
149 TEST (b, 46, -1);
150 TEST (b, 47, 1);
151 TEST (b, 48, -1);
152 TEST (b, 49, 1);
153 TEST (b, 50, -1);
154 TEST (b, 51, 1);
155 TEST (b, 52, -1);
156 TEST (b, 53, 1);
157 TEST (b, 54, -1);
158 TEST (b, 55, 1);
159 TEST (b, 56, -1);
160 TEST (b, 57, 1);
161 TEST (b, 58, -1);
162 TEST (b, 59, 1);
163 TEST (b, 60, -1);
164 TEST (b, 61, 1);
165 TEST (b, 62, -1);
166 TEST (b, 63, 1);
167 TEST (b, 64, -1);
168
169 return 0;
170 }
171
172