Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 1 | // Test for the following situation: |
| 2 | // (1) global A is constructed. |
| 3 | // (2) exit() is called during construction of global B. |
| 4 | // (3) destructor of A reads uninitialized global C from another module. |
| 5 | // We do *not* want to report init-order bug in this case. |
| 6 | |
| 7 | // RUN: %clangxx_asan -O0 %s %p/Helpers/init-order-atexit-extra.cc -o %t |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 8 | // RUN: %env_asan_opts=strict_init_order=true not %run %t 2>&1 | FileCheck %s |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 9 | |
| 10 | #include <stdio.h> |
| 11 | #include <stdlib.h> |
| 12 | |
| 13 | void AccessC(); |
| 14 | |
| 15 | class A { |
| 16 | public: |
| 17 | A() { } |
| 18 | ~A() { AccessC(); printf("PASSED\n"); } |
| 19 | // CHECK-NOT: AddressSanitizer |
| 20 | // CHECK: PASSED |
| 21 | }; |
| 22 | |
| 23 | A a; |
| 24 | |
| 25 | class B { |
| 26 | public: |
| 27 | B() { exit(1); } |
| 28 | ~B() { } |
| 29 | }; |
| 30 | |
| 31 | B b; |