1// Ensure that output is the same but exit code depends on halt_on_error value
2// RUN: %clangxx_asan %s -o %t
3// RUN: %env_asan_opts="halt_on_error=0" %run %t 2>&1 | FileCheck %s
4// RUN: %env_asan_opts="halt_on_error=1" not %run %t 2>&1 | FileCheck %s
5// RUN: not %run %t 2>&1 | FileCheck %s
6// REQUIRES: leak-detection
7// UNSUPPORTED: android
8
9#include <stdlib.h>
10
11int f() {
12 volatile int *a = (int *)malloc(size: 20);
13 a[0] = 1;
14 return a[0];
15}
16
17int main() {
18 f();
19 f();
20}
21
22// CHECK: LeakSanitizer: detected memory leaks
23

source code of compiler-rt/test/asan/TestCases/Linux/recoverable-lsan.cpp