1 // RUN: %clangxx_tsan -O1 %s -o %t
2 // RUN: %env_tsan_opts=allocator_may_return_null=1 %run %t 2>&1 | FileCheck %s
7 void *p
= malloc((size_t)-1);
9 fprintf(stderr
, "FAIL malloc(-1) = %p\n", p
);
10 p
= malloc((size_t)-1 / 2);
12 fprintf(stderr
, "FAIL malloc(-1/2) = %p\n", p
);
13 p
= calloc((size_t)-1, (size_t)-1);
15 fprintf(stderr
, "FAIL calloc(-1, -1) = %p\n", p
);
16 p
= calloc((size_t)-1 / 2, (size_t)-1 / 2);
18 fprintf(stderr
, "FAIL calloc(-1/2, -1/2) = %p\n", p
);
19 fprintf(stderr
, "OK\n");
23 // CHECK-NOT: failed to allocate