1 // RUN: %clangxx_msan -O0 -g %s -o %t && %run %t
2 // RUN: %clangxx_msan -O0 -g -DPOSITIVE %s -o %t && not %run %t 2>&1 | FileCheck %s
11 #if defined(__NetBSD__)
12 #include <sys/param.h>
13 #if __NetBSD_Prereq__(9,99,17)
14 #define NETBSD_POSIX_ICONV 1
16 #define NETBSD_POSIX_ICONV 0
21 iconv_t cd
= iconv_open("ASCII", "ASCII");
22 assert(cd
!= (iconv_t
)-1);
25 strcpy(inbuf_
, "sample text");
27 #if defined(__NetBSD__) && !NETBSD_POSIX_ICONV
28 // Some OSes expect the 2nd argument of iconv(3) to be of type const char **
29 const char *inbuf
= inbuf_
;
33 char *outbuf
= outbuf_
;
34 size_t inbytesleft
= strlen(inbuf_
);
35 size_t outbytesleft
= sizeof(outbuf_
);
40 char *volatile p
= &u
;
46 res
= iconv(cd
, 0, 0, 0, 0);
47 assert(res
!= (size_t)-1);
49 res
= iconv(cd
, 0, 0, &outbuf
, &outbytesleft
);
50 assert(res
!= (size_t)-1);
52 res
= iconv(cd
, &inbuf
, &inbytesleft
, &outbuf
, &outbytesleft
);
53 // CHECK: MemorySanitizer: use-of-uninitialized-value
54 // CHECK: #0 {{.*}} in main {{.*}}iconv.cpp:[[@LINE-2]]
55 assert(res
!= (size_t)-1);
56 assert(inbytesleft
== 0);
58 assert(memcmp(inbuf_
, outbuf_
, strlen(inbuf_
)) == 0);