gcc/testsuite/g++.dg/opt/ptrintsum1.C
raw| 1 | // PR c++/4401 |
| 2 | // This testcase was miscompiled on 64-bit platforms, resulting to |
| 3 | // operating on a[0x100000000] instead of a[0]. |
| 4 | // { dg-do run } |
| 5 | // { dg-options "-O2" } |
| 6 | |
| 7 | char *a; |
| 8 | char b[] = "AAAA"; |
| 9 | |
| 10 | extern "C" void abort (void); |
| 11 | extern "C" void exit (int); |
| 12 | |
| 13 | void foo (void) |
| 14 | { |
| 15 | unsigned int i, j; |
| 16 | |
| 17 | i = 2; |
| 18 | j = 3; |
| 19 | a[i + 1 - j] += i; |
| 20 | } |
| 21 | |
| 22 | int main (void) |
| 23 | { |
| 24 | a = b; |
| 25 | foo (); |
| 26 | if (b[0] != 'A' + 2) |
| 27 | abort (); |
| 28 | exit (0); |
| 29 | } |