Opened 7 years ago
#12083 new Bugs
Rounding mode not restored when using save_state rounding struct on x64
Reported by: | Owned by: | Douglas Gregor | |
---|---|---|---|
Milestone: | To Be Determined | Component: | numeric |
Version: | Boost 1.60.0 | Severity: | Showstopper |
Keywords: | interval numeric rounding | Cc: |
Description
The rounding mode is not restored when using interval_lib's save_state rounding struct on x64 when an exception is thrown (Visual Studio 2013/2015). This can have critical impact on applications. All rounding will remain downward after catching the exception. This bug does not occur in Win32.
We've also reported this issue to Microsoft: https://connect.microsoft.com/VisualStudio/Feedback/Details/2487437
Boost Repro:
#include <boost/numeric/interval.hpp>
void test_interval_number::test_boost_rounding() {
try {
boost::numeric::interval<double>::traits_type::rounding rnd; rnd.downward();
throw 1;
} catch (...) {
}
unsigned int fpu_flags = 0; errno_t err;
err = _controlfp_s(&fpu_flags, 0, 0); assert(err == 0);
assert((fpu_flags & _MCW_RC) != _RC_DOWN);
}