diff --git a/src/fileFormats/vtk/file/foamVtkFileWriter.C b/src/fileFormats/vtk/file/foamVtkFileWriter.C
index 3cc8b7e72a529ed650fe8ef0446bcfa6c26cb1c8..48afd2f3146e0a6dc3691803afdf837b5abbd2da 100644
--- a/src/fileFormats/vtk/file/foamVtkFileWriter.C
+++ b/src/fileFormats/vtk/file/foamVtkFileWriter.C
@@ -49,6 +49,18 @@ Foam::vtk::fileWriter::stateNames
 
 // * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * //
 
+void Foam::vtk::fileWriter::checkFormatterValidity() const
+{
+    // In parallel can be unallocated on non-master nodes
+    if ((parallel_ ? Pstream::master() : true) && !format_)
+    {
+        FatalErrorInFunction
+            << "unallocated formatter" << endl
+            << exit(FatalError);
+    }
+}
+
+
 Foam::Ostream& Foam::vtk::fileWriter::reportBadState
 (
     Ostream& os,
@@ -285,7 +297,7 @@ Foam::vtk::fileWriter::fileWriter
     nCellData_(0),
     nPointData_(0),
     outputFile_(),
-    format_(),
+    format_(nullptr),
     os_()
 {
     // We do not currently support append mode at all
@@ -313,7 +325,7 @@ bool Foam::vtk::fileWriter::open(const fileName& file, bool parallel)
 
     if (format_)
     {
-        format_.clear();
+        format_.reset(nullptr);
         os_.close();
     }
     nCellData_ = nPointData_ = 0;
@@ -368,7 +380,7 @@ void Foam::vtk::fileWriter::close()
 
     if (format_)
     {
-        format_.clear();
+        format_.reset(nullptr);
         os_.close();
     }
 
diff --git a/src/fileFormats/vtk/file/foamVtkFileWriter.H b/src/fileFormats/vtk/file/foamVtkFileWriter.H
index ea25b303232e9b08928a9258f279f28400a2c754..cb9b6a371d0d0a2f7907f659eafb559e966fc683 100644
--- a/src/fileFormats/vtk/file/foamVtkFileWriter.H
+++ b/src/fileFormats/vtk/file/foamVtkFileWriter.H
@@ -116,6 +116,9 @@ protected:
 
     // Protected Member Functions
 
+        //- Verify that formatter in either allocated or not required
+        void checkFormatterValidity() const;
+
         //- Generate message reporting bad writer state
         Ostream& reportBadState(Ostream&, outputState expected) const;
 
diff --git a/src/meshTools/output/vtk/mesh/foamVtkInternalMeshWriter.C b/src/meshTools/output/vtk/mesh/foamVtkInternalMeshWriter.C
index a5ee5abd525f71d960702c418a7f9700d47266cb..adae39e5609da16ef13c760b86320d628ee5615d 100644
--- a/src/meshTools/output/vtk/mesh/foamVtkInternalMeshWriter.C
+++ b/src/meshTools/output/vtk/mesh/foamVtkInternalMeshWriter.C
@@ -315,6 +315,11 @@ void Foam::vtk::internalMeshWriter::writeCellsConnectivity
         }
         else
         {
+// FIXME: clang-13 optimization jumps into incorrect branch
+            #ifdef __clang__
+            checkFormatterValidity();
+            #endif
+
             vtk::writeList(format(), cellTypes);
         }