From 942a0713749ddf53cdc0a9a13f00693c2548cbc8 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Tue, 1 Mar 2011 16:54:21 +0000 Subject: [PATCH] Workaround for VC9/VC10 (in the testsuite only) With /O2 and /fp:strict, MSVC produces a wrong assembler for the following code: int main(){ int i = 3; float f = 3.f; bool b = (f>= i); return b ? 0 : 1; } The issue is with constant propagation and /fp:strict in the optimizer. The workaround is to use volatile to prevent the constant propagation. --- .../include/CGAL/Test/_test_coercion_traits.h | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Algebraic_foundations/include/CGAL/Test/_test_coercion_traits.h b/Algebraic_foundations/include/CGAL/Test/_test_coercion_traits.h index 90796075aca..dd8b749ac5a 100644 --- a/Algebraic_foundations/include/CGAL/Test/_test_coercion_traits.h +++ b/Algebraic_foundations/include/CGAL/Test/_test_coercion_traits.h @@ -46,8 +46,21 @@ void test_implicit_interoperable_for_real_embeddable (CGAL::Tag_false){} template void test_implicit_interoperable_for_real_embeddable (CGAL::Tag_true){ // two sided test for interoperability with int - A a; - B b; + volatile A a; + volatile B b; + // These variables are volatile because the MSVC optimizer (at least VC9 + // and VC10) has problems with the following code with /O2 and /fp:strict + // (it does constant propagation but produces erroneous assembler code). + // Volatile prevents the constant propagation. + /* + int main(){ + int i = 3; + float f = 3.f; + bool b = (f>= i); + return b ? 0 : 1; + } + */ + a = A(-5); b = B(-2); // a < b