Relax assert to avoid spurious failures with /dev/null.
[oota-llvm.git] / include / llvm / Support / raw_ostream.h
index ed9c8b09ba474e3f616bb3f64f22f4eb3e1955f0..b59317112c4400616787588b305ab2daba8b1c2a 100644 (file)
@@ -323,7 +323,13 @@ public:
   explicit raw_pwrite_stream(bool Unbuffered = false)
       : raw_ostream(Unbuffered) {}
   void pwrite(const char *Ptr, size_t Size, uint64_t Offset) {
-    assert(Size + Offset <= tell() && "We don't support extending the stream");
+#ifndef NDBEBUG
+    uint64_t Pos = tell();
+    // /dev/null always reports a pos of 0, so we cannot perform this check
+    // in that case.
+    if (Pos)
+      assert(Size + Offset <= Pos && "We don't support extending the stream");
+#endif
     pwrite_impl(Ptr, Size, Offset);
   }
 };