1 // Test for LeakSanitizer+AddressSanitizer of different sizes.
2 // REQUIRES: leak-detection
4 // RUN: %clangxx_asan -O0 %s -o %t
5 // RUN: not %run %t 0 2>&1 | FileCheck %s
6 // RUN: not %run %t 1 2>&1 | FileCheck %s
7 // RUN: not %run %t 1000 2>&1 | FileCheck %s
8 // RUN: not %run %t 1000000 2>&1 | FileCheck %s
13 __attribute__((noopt
)) void leak(int n
) {
14 #if defined(__ANDROID__) || defined(__BIONIC__)
15 // Bionic does not acutally allocate when n==0, hence
16 // there would not be a leak.
17 // Re-adjust n so the test can pass.
22 // Repeat few times to make sure that at least one pointer is
23 // not somewhere on the stack.
24 for (int i
= 0; i
< 10; ++i
) {
25 volatile int *t
= new int[n
];
30 int main(int argc
, char **argv
) {
33 // CHECK: LeakSanitizer: detected memory leaks