• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // BUILD: clang -fsanitize=address a.cpp b.cpp -o IO-a
2 // BUILD: clang -fsanitize=address b.cpp a.cpp -o IO-b (noexpect)
3 
4 // ASAN_OPTIONS=check_initialization_order=true IO-a
5 // ASAN_OPTIONS=check_initialization_order=true IO-b (noexpect)
6 // CHECK: AddressSanitizer: Initialization-order-fiasco
7 
8 #include <cstdio>
9 
10 extern int extern_global;
11 
read_extern_global()12 int __attribute__((noinline)) read_extern_global()
13 {
14     return extern_global;
15 }
16 
17 int x = read_extern_global() + 1;
18 
main()19 int main()
20 {
21     printf("%d\n", x);
22     return 0;
23 }
24