Fix a bug with MSVC 2012 (VC11), in Interval_nt

The bug seems actually in VC11, but we use a workaround. The issue is how
the compilateur optimizes, or not, the expression tested by an assertion.
This commit is contained in:
Laurent Rineau 2013-02-26 15:46:14 +01:00
parent 02ff1276c2
commit d345f1bafd
1 changed files with 5 additions and 3 deletions

View File

@ -131,9 +131,11 @@ public:
Interval_nt(double i, double s)
: _inf(i), _sup(s)
{
// VC++ should use instead : (i<=s) || !is_valid(i) || !is_valid(s)
// Or should I use is_valid() ? or is_valid_or_nan() ?
CGAL_assertion_msg(!(i>s),
// Previously it was:
// CGAL_assertion_msg(!(i>s);
// But MSVC++ 2012 optimizes the test "!(i>s)" to "i<=s", even with
// /fp:strict. If 'i' or 's' is a NaN, that makes a difference.
CGAL_assertion_msg( (!is_valid(i)) || (!is_valid(s)) || (!(i>s)),
" Variable used before being initialized (or CGAL bug)");
#ifndef CGAL_DISABLE_ROUNDING_MATH_CHECK
CGAL_assertion_code((void) tester;) // Necessary to trigger a runtime test of rounding modes.