summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/asan/lit_tests/init-order-atexit.cc
diff options
context:
space:
mode:
Diffstat (limited to 'compiler-rt/lib/asan/lit_tests/init-order-atexit.cc')
-rw-r--r--compiler-rt/lib/asan/lit_tests/init-order-atexit.cc31
1 files changed, 31 insertions, 0 deletions
diff --git a/compiler-rt/lib/asan/lit_tests/init-order-atexit.cc b/compiler-rt/lib/asan/lit_tests/init-order-atexit.cc
new file mode 100644
index 00000000000..45f4f17c0cb
--- /dev/null
+++ b/compiler-rt/lib/asan/lit_tests/init-order-atexit.cc
@@ -0,0 +1,31 @@
+// Test for the following situation:
+// (1) global A is constructed.
+// (2) exit() is called during construction of global B.
+// (3) destructor of A reads uninitialized global C from another module.
+// We do *not* want to report init-order bug in this case.
+
+// RUN: %clangxx_asan -m64 -O0 %s %p/Helpers/init-order-atexit-extra.cc -o %t
+// RUN: ASAN_OPTIONS=check_initialization_order=true:strict_init_order=true %t 2>&1 | FileCheck %s
+
+#include <stdio.h>
+#include <stdlib.h>
+
+void AccessC();
+
+class A {
+ public:
+ A() { }
+ ~A() { AccessC(); printf("PASSED\n"); }
+ // CHECK-NOT: AddressSanitizer
+ // CHECK: PASSED
+};
+
+A a;
+
+class B {
+ public:
+ B() { exit(1); }
+ ~B() { }
+};
+
+B b;
OpenPOWER on IntegriCloud