File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 1+ // RUN: %clang_msan -Wno-alloc-size -fsanitize-recover=memory %s -o %t && not %run %t 2>&1 | FileCheck %s
2+
3+ // XFAIL: *
4+
5+ #include < malloc.h>
6+ #include < stdio.h>
7+
8+ int main (int argc, char **argv) {
9+ {
10+ char * p1 = (char *)calloc (1 , 0 );
11+ printf (" p1 is %p\n " , p1);
12+ printf (" Content of p1 is: %d\n " , *p1);
13+ // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value
14+ // CHECK: {{#0 0x.* in main .*zero_alloc.cpp:}}[[@LINE-2]]
15+ free (p1);
16+ }
17+
18+ {
19+ char * p2 = (char *)calloc (0 , 1 );
20+ printf (" p2 is %p\n " , p2);
21+ printf (" Content of p2 is: %d\n " , *p2);
22+ // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value
23+ // CHECK: {{#0 0x.* in main .*zero_alloc.cpp:}}[[@LINE-2]]
24+ free (p2);
25+ }
26+
27+ {
28+ char * p3 = (char *)malloc (0 );
29+ printf (" p3 is %p\n " , p3);
30+ printf (" Content of p2 is: %d\n " , *p3);
31+ // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value
32+ // CHECK: {{#0 0x.* in main .*zero_alloc.cpp:}}[[@LINE-2]]
33+ free (p3);
34+ }
35+
36+ return 0 ;
37+ }
You can’t perform that action at this time.
0 commit comments