1 // RUN: %clangxx_msan -O0 -g %s -o %t && %run %t
2 // RUN: %clangxx_msan -O3 -g %s -o %t && %run %t
4 // RUN: %clangxx_msan -DPOSITIVE -O0 -g %s -o %t && not %run %t 2>&1 | FileCheck %s
5 // RUN: %clangxx_msan -DPOSITIVE -O3 -g %s -o %t && not %run %t 2>&1 | FileCheck %s
7 // Reports different report (not analyzed)
8 // XFAIL: target={{.*netbsd.*}}
15 #include <sys/ioctl.h>
16 #include <sys/socket.h>
19 int main(int argc
, char **argv
) {
20 int fd
= socket(AF_UNIX
, SOCK_STREAM
, 0);
22 struct ifreq ifreqs
[20];
24 ifc
.ifc_ifcu
.ifcu_req
= ifreqs
;
26 ifc
.ifc_len
= sizeof(ifreqs
);
28 int res
= ioctl(fd
, SIOCGIFCONF
, (void *)&ifc
);
29 // CHECK: Uninitialized bytes in ioctl{{.*}} at offset 0 inside [0x{{.*}}, 4)
30 // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value
31 // CHECK: #{{.*}} in main {{.*}}ioctl_custom.cpp:[[@LINE-3]]
33 for (int i
= 0; i
< ifc
.ifc_len
/ sizeof(*ifc
.ifc_ifcu
.ifcu_req
); ++i
)
34 printf("%d %zu %s\n", i
, strlen(ifreqs
[i
].ifr_name
), ifreqs
[i
].ifr_name
);