1// Test that realloc(nullptr, 0) return a non-NULL pointer.
2
3// RUN: %clang_tsan %s -o %t
4// RUN: %run %t 2>&1 | FileCheck %s
5
6#include <malloc/malloc.h>
7#include <stdio.h>
8#include <stdlib.h>
9#include <sys/mman.h>
10
11int main() {
12 void *p = realloc(NULL, size: 0);
13 if (!p) {
14 abort();
15 }
16 fprintf(stderr, format: "Okay.\n");
17 return 0;
18}
19
20// CHECK: Okay.
21

source code of compiler-rt/test/tsan/Darwin/realloc-zero.cpp