[PATCH] D49404: [libFuzzer] Avoid std::cout in SimpleTest.

Matt Morehouse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 16 15:43:58 PDT 2018


morehouse created this revision.
morehouse added a reviewer: kcc.

When linked with libc++, std::cout can cause MSan false positives.


https://reviews.llvm.org/D49404

Files:
  compiler-rt/test/fuzzer/SimpleTest.cpp


Index: compiler-rt/test/fuzzer/SimpleTest.cpp
===================================================================
--- compiler-rt/test/fuzzer/SimpleTest.cpp
+++ compiler-rt/test/fuzzer/SimpleTest.cpp
@@ -3,11 +3,9 @@
 
 // Simple test for a fuzzer. The fuzzer must find the string "Hi!".
 #include <assert.h>
-#include <cstddef>
 #include <cstdint>
+#include <cstdio>
 #include <cstdlib>
-#include <iostream>
-#include <ostream>
 
 static volatile int Sink;
 
@@ -18,7 +16,8 @@
     if (Size > 1 && Data[1] == 'i') {
       Sink = 2;
       if (Size > 2 && Data[2] == '!') {
-        std::cout << "BINGO; Found the target, exiting\n" << std::flush;
+        printf("BINGO; Found the target, exiting\n");
+        fflush(stdout);
         exit(0);
       }
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49404.155774.patch
Type: text/x-patch
Size: 763 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180716/93bae840/attachment.bin>


More information about the llvm-commits mailing list