1 // RUN: %clangxx_msan -O0 %s -o %t && not %run %t >%t.out 2>&1
2 // RUN: FileCheck %s < %t.out
3 // RUN: %clangxx_msan -O3 %s -o %t && not %run %t >%t.out 2>&1
4 // RUN: FileCheck %s < %t.out
5 
6 #include <sys/types.h>
7 #include <sys/socket.h>
8 #include <netdb.h>
9 #include <stdlib.h>
10 
11 volatile int z;
12 
main(void)13 int main(void) {
14   struct addrinfo *ai;
15   struct addrinfo hint;
16   int res = getaddrinfo("localhost", NULL, NULL, &ai);
17   if (ai) z = 1; // OK
18   res = getaddrinfo("localhost", NULL, &hint, &ai);
19   // CHECK: Uninitialized bytes in __interceptor_getaddrinfo at offset 0 inside [0x{{.*}}, 48)
20   // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value
21   // CHECK: #0 {{.*}} in main {{.*}}getaddrinfo-positive.cc:[[@LINE-3]]
22   return 0;
23 }
24