gcc/testsuite/gcc.dg/pr103721-2.c
raw| 1 | // { dg-do run } |
| 2 | // { dg-require-effective-target thread_fence } |
| 3 | // { dg-options "-O2" } |
| 4 | |
| 5 | extern void abort (); |
| 6 | struct S { int x; } a[10]; |
| 7 | struct S *b; |
| 8 | |
| 9 | int |
| 10 | main () |
| 11 | { |
| 12 | int i, j = 0; |
| 13 | struct S *q = a; |
| 14 | |
| 15 | for (i = 100; --i > 0; ) |
| 16 | { |
| 17 | struct S *p; |
| 18 | j++; |
| 19 | if (j >= 10) |
| 20 | j = 0; |
| 21 | p = &a[j]; |
| 22 | |
| 23 | if (p == q) |
| 24 | abort (); |
| 25 | __atomic_thread_fence (__ATOMIC_SEQ_CST); |
| 26 | q = p; |
| 27 | } |
| 28 | return 0; |
| 29 | } |