| 1 |
void abort (void); |
| 2 |
|
| 3 |
void f (int *p, int **q) |
| 4 |
{ |
| 5 |
int i; |
| 6 |
for (i = 0; i < 40; i++) |
| 7 |
{ |
| 8 |
*q++ = &p[i]; |
| 9 |
} |
| 10 |
} |
| 11 |
|
| 12 |
int main () |
| 13 |
{ |
| 14 |
void *p; |
| 15 |
int *q[40]; |
| 16 |
__SIZE_TYPE__ start; |
| 17 |
|
| 18 |
/* Find the signed middle of the address space. */ |
| 19 |
if (sizeof(start) == sizeof(int)) |
| 20 |
start = (__SIZE_TYPE__) __INT_MAX__; |
| 21 |
else if (sizeof(start) == sizeof(long)) |
| 22 |
start = (__SIZE_TYPE__) __LONG_MAX__; |
| 23 |
else if (sizeof(start) == sizeof(long long)) |
| 24 |
start = (__SIZE_TYPE__) __LONG_LONG_MAX__; |
| 25 |
else |
| 26 |
return 0; |
| 27 |
|
| 28 |
/* Arbitrarily align the pointer. */ |
| 29 |
start &= -32; |
| 30 |
|
| 31 |
/* Pretend that's good enough to start address arithmetic. */ |
| 32 |
p = (void *)start; |
| 33 |
|
| 34 |
/* Verify that GIV replacement computes the correct results. */ |
| 35 |
q[39] = 0; |
| 36 |
f (p, q); |
| 37 |
if (q[39] != (int *)p + 39) |
| 38 |
abort (); |
| 39 |
|
| 40 |
return 0; |
| 41 |
} |