]> git.proxmox.com Git - rustc.git/blame - src/compiler-rt/test/asan/TestCases/Windows/dll_operator_array_new_left_oob.cc
New upstream version 1.19.0+dfsg3
[rustc.git] / src / compiler-rt / test / asan / TestCases / Windows / dll_operator_array_new_left_oob.cc
CommitLineData
92a42be0
SL
1// RUN: %clang_cl_asan -O0 %p/dll_host.cc -Fe%t
2// RUN: %clang_cl_asan -LD -O0 %s -Fe%t.dll
3// RUN: not %run %t %t.dll 2>&1 | FileCheck %s
4
5extern "C" __declspec(dllexport)
6int test_function() {
7 char *buffer = new char[42];
8 buffer[-1] = 42;
9// CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
10// CHECK: WRITE of size 1 at [[ADDR]] thread T0
11// CHECK-NEXT: test_function {{.*}}dll_operator_array_new_left_oob.cc:[[@LINE-3]]
12// CHECK-NEXT: main {{.*}}dll_host.cc
13//
14// CHECK: [[ADDR]] is located 1 bytes to the left of 42-byte region
15// CHECK-LABEL: allocated by thread T0 here:
16// FIXME: Should get rid of the malloc/free frames called from the inside of
17// operator new/delete in DLLs when using -MT CRT.
18// FIXME: The 'operator new' frame should have [].
19// CHECK: operator new
20// CHECK-NEXT: test_function {{.*}}dll_operator_array_new_left_oob.cc:[[@LINE-13]]
21// CHECK-NEXT: main {{.*}}dll_host.cc
22// CHECK-LABEL: SUMMARY
23 delete [] buffer;
24 return 0;
25}