1// RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
2#include <pthread.h>
3
4volatile int N; // Prevent loop unrolling.
5int **data;
6
7void *Thread1(void *x) {
8 for (int i = 0; i < N; i++)
9 data[i][0] = 42;
10 return 0;
11}
12
13int main() {
14 N = 4;
15 data = new int*[N];
16 for (int i = 0; i < N; i++)
17 data[i] = new int;
18 pthread_t t;
19 pthread_create(newthread: &t, attr: 0, start_routine: Thread1, arg: 0);
20 Thread1(x: 0);
21 pthread_join(th: t, thread_return: 0);
22 for (int i = 0; i < N; i++)
23 delete data[i];
24 delete[] data;
25}
26
27// CHECK: ThreadSanitizer: reported 1 warnings
28

source code of compiler-rt/test/tsan/suppress_same_stacks.cpp