Mercurial > hg > CbC > CbC_llvm
view compiler-rt/test/tsan/malloc_overflow.cpp @ 266:00f31e85ec16 default tip
Added tag current for changeset 31d058e83c98
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 14 Oct 2023 10:13:55 +0900 |
parents | 1d019706d866 |
children |
line wrap: on
line source
// RUN: %clangxx_tsan -O1 %s -o %t // RUN: %env_tsan_opts=allocator_may_return_null=1 %run %t 2>&1 | FileCheck %s #include <stdio.h> #include <stdlib.h> int main() { void *p = malloc((size_t)-1); if (p != 0) fprintf(stderr, "FAIL malloc(-1) = %p\n", p); p = malloc((size_t)-1 / 2); if (p != 0) fprintf(stderr, "FAIL malloc(-1/2) = %p\n", p); p = calloc((size_t)-1, (size_t)-1); if (p != 0) fprintf(stderr, "FAIL calloc(-1, -1) = %p\n", p); p = calloc((size_t)-1 / 2, (size_t)-1 / 2); if (p != 0) fprintf(stderr, "FAIL calloc(-1/2, -1/2) = %p\n", p); fprintf(stderr, "OK\n"); } // CHECK-NOT: FAIL // CHECK-NOT: failed to allocate