brintos

brintos / llvm-project-archived public Read only

0
0
Text · 639 B · 9980d11 Raw
35 lines · cpp
1// RUN: %clangxx_msan -g %s -o %t2// RUN: not %run %t 2>&1 | FileCheck %s3// RUN: %t 14 5#include <stdio.h>6#include <stdlib.h>7 8int test_fread() {9  FILE *f = fopen("/dev/zero", "r");10  char c;11  unsigned read = fread(&c, sizeof(c), 1, f);12  fclose(f);13  if (c == '1') // No error14    return 1;15  return 0;16}17 18int test_fwrite() {19  FILE *f = fopen("/dev/null", "w");20  char c;21  if (fwrite(&c, sizeof(c), 1, f) != sizeof(c)) // BOOM22    return 1;23  return fclose(f);24}25 26int main(int argc, char *argv[]) {27  if (argc > 1)28    test_fread();29  else30    test_fwrite();31  return 0;32}33 34// CHECK: Uninitialized bytes in fwrite at offset 0 inside35