Mercurial > hg > CbC > CbC_gcc
diff gcc/testsuite/g++.dg/opt/ptrintsum1.C @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gcc/testsuite/g++.dg/opt/ptrintsum1.C Fri Oct 27 22:46:09 2017 +0900 @@ -0,0 +1,29 @@ +// PR c++/4401 +// This testcase was miscompiled on 64-bit platforms, resulting to +// operating on a[0x100000000] instead of a[0]. +// { dg-do run } +// { dg-options "-O2" } + +char *a; +char b[] = "AAAA"; + +extern "C" void abort (void); +extern "C" void exit (int); + +void foo (void) +{ + unsigned int i, j; + + i = 2; + j = 3; + a[i + 1 - j] += i; +} + +int main (void) +{ + a = b; + foo (); + if (b[0] != 'A' + 2) + abort (); + exit (0); +}