| 1 | // RUN: %clang_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s |
|---|---|
| 2 | |
| 3 | #include <stdio.h> |
| 4 | #include <stdlib.h> |
| 5 | |
| 6 | int n; |
| 7 | const int N = 10000; |
| 8 | |
| 9 | static void atexit1() { |
| 10 | n++; |
| 11 | } |
| 12 | |
| 13 | static void atexit0() { |
| 14 | fprintf(stderr, format: "run count: %d\n", n); |
| 15 | } |
| 16 | |
| 17 | int main() { |
| 18 | atexit(func: atexit0); |
| 19 | for (int i = 0; i < N; i++) |
| 20 | atexit(func: atexit1); |
| 21 | } |
| 22 | |
| 23 | // CHECK-NOT: FATAL: ThreadSanitizer |
| 24 | // CHECK-NOT: WARNING: ThreadSanitizer |
| 25 | // CHECK: run count: 10000 |
| 26 | |
| 27 |
