1// RUN: %clangxx_msan -fsanitize-memory-track-origins -O0 %s -o %t
2// RUN: %run %t
3// RUN: %clangxx_msan -fsanitize-memory-track-origins -O3 %s -o %t
4// RUN: %run %t
5
6#include <assert.h>
7#include <string.h>
8#include <sanitizer/msan_interface.h>
9
10int main(int argc, char **argv) {
11 char s[20] = "string";
12 __msan_poison(a: s, size: sizeof(s));
13 __msan_unpoison_string(a: s);
14 assert(__msan_test_shadow(s, sizeof(s)) == strlen("string") + 1);
15 return 0;
16}
17

source code of compiler-rt/test/msan/unpoison_string.cpp