1// RUN: %clangxx_msan -O0 -g %s -o %t && %run %t
2
3#include <assert.h>
4#include <sanitizer/msan_interface.h>
5#include <semaphore.h>
6
7int main(void) {
8 sem_t sem;
9 int res = sem_init(sem: &sem, pshared: 0, value: 42);
10 assert(res == 0);
11
12 int v;
13 res = sem_getvalue(sem: &sem, sval: &v);
14 assert(res == 0);
15 __msan_check_mem_is_initialized(x: &v, size: sizeof(v));
16 assert(v == 42);
17
18 res = sem_destroy(sem: &sem);
19 assert(res == 0);
20
21 return 0;
22}
23

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