aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/pr103721-2.c
blob: aefa1f0f147389512574d242116912d77b96f4ae (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
// { dg-do run }
// { dg-options "-O2" }

extern void abort ();
struct S { int x; } a[10];
struct S *b;

int
main ()
{
  int i, j = 0;
  struct S *q = a;

  for (i = 100; --i > 0; )
    {
      struct S *p;
      j++;
      if (j >= 10)
        j = 0;
      p = &a[j];

      if (p == q)
        abort ();
      __atomic_thread_fence (__ATOMIC_SEQ_CST);
      q = p;
    }
  return 0;
}