1 | // Workaround for "LINK : fatal error LNK1318: Unexpected PDB error" |
2 | // RUN: rm -f %t.pdb |
3 | |
4 | // RUN: %clang_cl_asan %s -o %t.exe |
5 | // RUN: %run %t.exe 2>&1 | FileCheck %s |
6 | // RUN: %clang_cl %s -o %t.exe |
7 | // RUN: %run %t.exe 2>&1 | FileCheck %s |
8 | |
9 | #include <cassert> |
10 | #include <stdio.h> |
11 | #include <windows.h> |
12 | |
13 | int main() { |
14 | void *p = calloc(1, 100); |
15 | assert(p); |
16 | void *np = _recalloc(p, 2, 100); |
17 | assert(np); |
18 | for (int i = 0; i < 2 * 100; i++) { |
19 | assert(((BYTE *)np)[i] == 0); |
20 | } |
21 | void *nnp = _recalloc(np, 1, 100); |
22 | assert(nnp); |
23 | for (int i = 0; i < 100; i++) { |
24 | assert(((BYTE *)nnp)[i] == 0); |
25 | ((BYTE *)nnp)[i] = 0x0d; |
26 | } |
27 | void *nnnp = _recalloc(nnp, 2, 100); |
28 | assert(nnnp); |
29 | for (int i = 0; i < 100; i++) { |
30 | assert(((BYTE *)nnnp)[i] == 0x0d); |
31 | } |
32 | for (int i = 100; i < 200; i++) { |
33 | assert(((BYTE *)nnnp)[i] == 0); |
34 | } |
35 | fprintf(stderr, format: "passed\n" ); |
36 | return 0; |
37 | } |
38 | |
39 | // CHECK-NOT: Assertion |
40 | // CHECK: passed |
41 | |