summaryrefslogtreecommitdiff
path: root/test/msan/open_memstream.cc
blob: af3f795d9353959f960737b61046844547536d1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// RUN: %clangxx_msan -m64 -O0 -g -xc++ %s -o %t && %t
// RUN: %clangxx_msan -m64 -O3 -g -xc++ %s -o %t && %t

#include <stdio.h>
#include <stdlib.h>

int main(void) {
  char *buf;
  size_t buf_len = 42;
  FILE *fp = open_memstream(&buf, &buf_len);
  fprintf(fp, "hello");
  fflush(fp);
  printf("buf_len = %zu\n", buf_len);
  for (int j = 0; j < buf_len; j++) {
    printf("buf[%d] = %c\n", j, buf[j]);
  }
  return 0;
}