From 5f0e151b1fb7dc75283ccab437e9815c2da80e13 Mon Sep 17 00:00:00 2001 From: Dmitri Naumov Date: Wed, 3 Jan 2024 11:36:04 +0100 Subject: [PATCH] [MeL] Disable FPE for reading vtu files Reading the VTU files can trigger floating point exceptions. Because we are not debugging VTK (or other libraries) at this point, the floating point exceptions are temporarily disabled and are restored at the end of the scope. --- MeshLib/IO/VtkIO/VtuInterface.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/MeshLib/IO/VtkIO/VtuInterface.cpp b/MeshLib/IO/VtkIO/VtuInterface.cpp index acc85ccf80e..757064ae482 100644 --- a/MeshLib/IO/VtkIO/VtuInterface.cpp +++ b/MeshLib/IO/VtkIO/VtuInterface.cpp @@ -25,6 +25,7 @@ #include +#include "BaseLib/DisableFPE.h" #include "BaseLib/Logging.h" #ifdef USE_PETSC @@ -62,7 +63,14 @@ MeshLib::Mesh* VtuInterface::readVTUFile(std::string const& file_name) vtkSmartPointer reader = vtkSmartPointer::New(); reader->SetFileName(file_name.c_str()); - reader->Update(); + { + // Reading the VTU files can trigger floating point exceptions. Because + // we are not debugging VTK (or other libraries) at this point, the + // floating point exceptions are temporarily disabled and are restored + // at the end of the scope. + [[maybe_unused]] DisableFPE disable_fpe; + reader->Update(); + } vtkUnstructuredGrid* vtkGrid = reader->GetOutput(); if (vtkGrid->GetNumberOfPoints() == 0)