summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/opt/ptrintsum1.C
blob: a6a3c9727db059b587cf6edf8c30d82b33263af2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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);
}