-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathtest.c
46 lines (35 loc) · 842 Bytes
/
test.c
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include "stdatomic.h"
#include "threads.h"
_Atomic int g1; // COMPLIANT
_Atomic int g2 = 0; // COMPLIANT
void f_thread(void *x);
void f_starts_thread() {
thrd_t t;
thrd_create(&t, f_thread, 0);
}
void f_may_initialize_argument(void *p1) {}
void main() {
_Atomic int l1 = 1; // COMPLIANT
f_starts_thread();
_Atomic int l2; // COMPLIANT
atomic_init(&l2, 0);
f_starts_thread();
_Atomic int l3; // NON-COMPLIANT
f_starts_thread();
_Atomic int l4; // NON-COMPLIANT
f_starts_thread();
atomic_init(&l4, 0);
_Atomic int l5; // NON-COMPLIANT
if (g1 == 0) {
atomic_init(&l5, 0);
}
f_starts_thread();
_Atomic int l6; // COMPLIANT
f_may_initialize_argument(&l6);
f_starts_thread();
_Atomic int l7; // NON_COMPLIANT
if (g1 == 0) {
f_may_initialize_argument(&l7);
}
f_starts_thread();
}