summaryrefslogtreecommitdiffstats
path: root/compiler-rt/test/tsan/atexit2.cpp
blob: 6f74c5f9f6e510a18ae5e031f525b7185e463466 (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
// RUN: %clang_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s

#include <stdio.h>
#include <stdlib.h>

int n;
const int N = 10000;

static void atexit1() {
  n++;
}

static void atexit0() {
  fprintf(stderr, "run count: %d\n", n);
}

int main() {
  atexit(atexit0);
  for (int i = 0; i < N; i++)
    atexit(atexit1);
}

// CHECK-NOT: FATAL: ThreadSanitizer
// CHECK-NOT: WARNING: ThreadSanitizer
// CHECK: run count: 10000

OpenPOWER on IntegriCloud