| 1 |
int st = 1; |
| 2 |
static void __attribute__((noinline)) |
| 3 |
foo (int a[], int n) |
| 4 |
{ |
| 5 |
int i; |
| 6 |
for (i = 0; i < n; i++) |
| 7 |
{ |
| 8 |
if (i < 25) |
| 9 |
a[i] = i; |
| 10 |
a[n - i] = 1; |
| 11 |
} |
| 12 |
} |
| 13 |
|
| 14 |
static int __attribute__((noinline)) |
| 15 |
array_sum (int a[]) |
| 16 |
{ |
| 17 |
int i, res = 0; |
| 18 |
for(i = 0; i < 50; i += st) |
| 19 |
res += a[i]; |
| 20 |
return res; |
| 21 |
} |
| 22 |
|
| 23 |
extern void abort (); |
| 24 |
|
| 25 |
int |
| 26 |
main (void) |
| 27 |
{ |
| 28 |
int a[51]; /* NB This size allows foo's first iteration to write to a[50]. */ |
| 29 |
foo (a, 50); |
| 30 |
int res = array_sum (a); |
| 31 |
if (res != 49) |
| 32 |
abort (); |
| 33 |
return 0; |
| 34 |
} |