Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / asan / TestCases / calloc-overflow.cpp
blob9a0d41ff8260187790c87d3a27b8bbc91ef04ade
1 // RUN: %clangxx_asan -O0 %s -o %t
2 // RUN: %env_asan_opts=allocator_may_return_null=0 not %run %t 2>&1 | FileCheck %s
3 // RUN: %env_asan_opts=allocator_may_return_null=1 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-NULL
5 // REQUIRES: stable-runtime
7 #include <stdio.h>
8 #include <stdlib.h>
10 int main() {
11 void *p = calloc(-1, 1000);
12 // CHECK: {{ERROR: AddressSanitizer: calloc parameters overflow: count \* size \(.* \* 1000\) cannot be represented in type size_t}}
13 // CHECK: {{#0 0x.* in .*calloc}}
14 // CHECK: {{#1 0x.* in main .*calloc-overflow.cpp:}}[[@LINE-3]]
15 // CHECK: SUMMARY: AddressSanitizer: calloc-overflow
17 printf("calloc returned: %zu\n", (size_t)p);
18 // CHECK-NULL: calloc returned: 0
20 return 0;