aboutsummaryrefslogtreecommitdiff
path: root/test/sanitizer_common/TestCases/Darwin/abort_on_error.cc
diff options
context:
space:
mode:
Diffstat (limited to 'test/sanitizer_common/TestCases/Darwin/abort_on_error.cc')
-rw-r--r--test/sanitizer_common/TestCases/Darwin/abort_on_error.cc19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/sanitizer_common/TestCases/Darwin/abort_on_error.cc b/test/sanitizer_common/TestCases/Darwin/abort_on_error.cc
new file mode 100644
index 000000000000..dbab5253d8c1
--- /dev/null
+++ b/test/sanitizer_common/TestCases/Darwin/abort_on_error.cc
@@ -0,0 +1,19 @@
+// Check that sanitizers on OS X crash the process by default (i.e.
+// abort_on_error=1). See also Linux/abort_on_error.cc.
+
+// RUN: %clangxx %s -o %t
+
+// Intentionally don't inherit the default options.
+// RUN: %tool_options='' not --crash %run %t 2>&1
+
+// When we use lit's default options, we shouldn't crash.
+// RUN: not %run %t 2>&1
+
+int global;
+
+int main() {
+ volatile int *a = new int[100];
+ delete[] a;
+ global = a[0]; // use-after-free: triggers ASan report.
+ return 0;
+}