27 lines · cpp
1// RUN: %clangxx_asan %min_macos_deployment_target=10.11 -O0 %s %p/Helpers/initialization-bug-extra.cpp -o %t2// RUN: %env_asan_opts=check_initialization_order=true:strict_init_order=true not %run %t 2>&1 | FileCheck %s3 4// Do not test with optimization -- the error may be optimized away.5 6// FIXME: https://code.google.com/p/address-sanitizer/issues/detail?id=1867// XFAIL: target={{.*windows-msvc.*}}8 9// Fails on some Darwin bots, probably iOS.10// XFAIL: ios11 12#include <stdio.h>13 14extern int y;15 16void __attribute__((constructor)) ctor() {17 printf("%d\n", y);18 // CHECK: AddressSanitizer: initialization-order-fiasco19}20 21int main() {22 // ASan should have caused an exit before main runs.23 printf("PASS\n");24 // CHECK-NOT: PASS25 return 0;26}27