1// RUN: %clang_cl_asan %Od %s %Fe%t
2// RUN: %run %t
3
4#include <windows.h>
5#include <process.h>
6
7unsigned WINAPI thread_proc(void *) {
8 volatile char stack_buffer[42];
9 for (int i = 0; i < sizeof(stack_buffer); ++i)
10 stack_buffer[i] = 42;
11 return 0;
12}
13
14int main() {
15 HANDLE thr = (HANDLE)_beginthreadex(NULL, 0, thread_proc, NULL, 0, NULL);
16 if (thr == 0)
17 return 1;
18 if (WAIT_OBJECT_0 != WaitForSingleObject(thr, INFINITE))
19 return 2;
20 CloseHandle(thr);
21}
22

source code of compiler-rt/test/asan/TestCases/Windows/beginthreadex.cpp