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