reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced
    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