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, 0, 42);
10  assert(res == 0);
11
12  int v;
13  res = sem_getvalue(&sem, &v);
14  assert(res == 0);
15  __msan_check_mem_is_initialized(&v, sizeof(v));
16  assert(v == 42);
17
18  res = sem_destroy(&sem);
19  assert(res == 0);
20
21  return 0;
22}
23