1 // RUN: %clang %s -o %t && %run %t
2 // Verify that even if iconv returned -1
3 // we still treat the initialized part of outbuf as properly initialized.
5 // UNSUPPORTED: android
12 iconv_t cd
= iconv_open("UTF-8", "no");
13 assert(cd
!= (iconv_t
)-1);
14 char in
[11] = {0x7e, 0x7e, 0x5f, 0x53, 0x55, 0x3e,
15 0x99, 0x3c, 0x7e, 0x7e, 0x7e};
16 fprintf(stderr
, "cd: %p\n", (void*)cd
);
19 size_t inbytesleft
= 11;
20 char *outbuf
= &out
[0];
21 size_t outbytesleft
= 100;
22 int ret
= iconv(cd
, &inbuf
, &inbytesleft
, &outbuf
, &outbytesleft
);
24 assert(outbuf
- &out
[0] == 10);
25 for (int i
= 0; i
< 10; i
++) {
26 if (out
[i
] == 0x77) return 1;
27 fprintf(stderr
, "OUT%d 0x%x -- OK\n", i
, (unsigned char)out
[i
]);