From d345f1bafdf9074002244fa1442ebb88762d679c Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Tue, 26 Feb 2013 15:46:14 +0100 Subject: [PATCH] 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. --- Number_types/include/CGAL/Interval_nt.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Number_types/include/CGAL/Interval_nt.h b/Number_types/include/CGAL/Interval_nt.h index 0bbc8c27cd7..a8a8c1fc5a3 100644 --- a/Number_types/include/CGAL/Interval_nt.h +++ b/Number_types/include/CGAL/Interval_nt.h @@ -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.