1 // RUN: %clang_cl_asan -Od %p/dll_host.cpp -Fe%t
2 // RUN: %clang_cl_asan -LD -Od %s -Fe%t.dll
3 // RUN: %run %t %t.dll 2>&1 | FileCheck %s
4
5 // Test that it works correctly even with ICF enabled.
6 // RUN: %clang_cl_asan -LD -Od %s -Fe%t.dll -link /OPT:REF /OPT:ICF
7 // RUN: %run %t %t.dll 2>&1 | FileCheck %s
8
9 #include <iostream>
10
11 extern "C" __declspec(dllexport)
test_function()12 int test_function() {
13 // Just make sure we can use cout.
14 std::cout << "All ok\n";
15 // CHECK: All ok
16
17 // This line forces a declaration of some global basic_ostream internal object that
18 // calls memcpy() in its constructor. This doesn't work if __asan_init is not
19 // called early enough.
20 std::cout << 42;
21 // CHECK: 42
22 return 0;
23 }
24