Fix rounding in vtkXMLReader(Writer)::UpdateProgressDiscrete to avoid FE_INEXACT
This PR fixes member function UpdateProgressDiscrete
found in vtkXMLReader
and vtkXMLWriter
. The function currently uses truncation from float
to int
as part of rounding to nearest percent. However, as demonstrated by this example, such truncation causes an FE_INEXACT
floating point exception to be raised on x86_64 platforms (under a wide variety of compilers and optimization levels). If VTK is used in a code that enables FPE trapping, any attempt to read or write a mesh may raise an FPE signal.
The proposed solution is to simply use std::round
from <cmath>
which performs correct rounding without raising the FPE.