Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / msan / Linux / sunrpc_string.cpp
blob76b53a7057c7eca02ce449043c359d2ff36d3c65
1 // REQUIRES: sunrpc
3 // RUN: %clangxx_msan -g -O0 %s -o %t && \
4 // RUN: %run %t 2>&1
5 // RUN: %clangxx_msan -g -O0 -DUNINIT=1 %s -o %t && \
6 // RUN: not %run %t 2>&1 | FileCheck %s
8 #include <assert.h>
9 #include <string.h>
10 #include <rpc/xdr.h>
12 #include <sanitizer/msan_interface.h>
14 int main(int argc, char *argv[]) {
15 XDR xdrs;
16 char buf[100];
17 xdrmem_create(&xdrs, buf, sizeof(buf), XDR_ENCODE);
18 char s[20];
19 #ifndef UNINIT
20 strcpy(s, "hello");
21 #endif
22 char *sp = s;
23 bool_t res = xdr_string(&xdrs, &sp, sizeof(s));
24 // CHECK: MemorySanitizer: use-of-uninitialized-value
25 // CHECK: {{in main.*sunrpc_string.cpp:}}[[@LINE-2]]
26 assert(res == TRUE);
27 xdr_destroy(&xdrs);
29 xdrmem_create(&xdrs, buf, sizeof(buf), XDR_DECODE);
30 char s2[20];
31 char *sp2 = s2;
32 res = xdr_string(&xdrs, &sp2, sizeof(s2));
33 assert(res == TRUE);
34 assert(strcmp(s, s2) == 0);
35 xdr_destroy(&xdrs);
36 return 0;