From ab296856c7a0edf9edcb1232f78cdbfeba9c9f7d Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 2 Mar 2011 09:59:27 +0000 Subject: [PATCH] New version of test_implicit_interoperable_for_real_embeddable: the variable a and b cannot be volatile, but they can be initialized from volatile values. Again, the goal is to prevent constant propagation. --- .../include/CGAL/Test/_test_coercion_traits.h | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/Algebraic_foundations/include/CGAL/Test/_test_coercion_traits.h b/Algebraic_foundations/include/CGAL/Test/_test_coercion_traits.h index dd8b749ac5a..02de4cef83d 100644 --- a/Algebraic_foundations/include/CGAL/Test/_test_coercion_traits.h +++ b/Algebraic_foundations/include/CGAL/Test/_test_coercion_traits.h @@ -46,12 +46,15 @@ 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 - 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. + A a; + B b; + + volatile int value_a = -5; + volatile int value_b = -5; + // 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). Using volatile variables prevents + // the constant propagation. /* int main(){ int i = 3; @@ -61,8 +64,8 @@ void test_implicit_interoperable_for_real_embeddable (CGAL::Tag_true){ } */ - a = A(-5); - b = B(-2); + a = A(value_a); + b = B(value_b); // a < b assert (!(a == b)); assert ( (a != b)); @@ -78,9 +81,11 @@ void test_implicit_interoperable_for_real_embeddable (CGAL::Tag_true){ assert ( (b > a)); assert ( (b >= a)); + value_a = 5; + value_b = 2; // a > b - a = A(5); - b = B(2); + a = A(value_a); + b = B(value_b); assert (!(a == b)); assert ( (a != b)); assert (!(a < b)); @@ -96,8 +101,10 @@ void test_implicit_interoperable_for_real_embeddable (CGAL::Tag_true){ assert (!(b >= a)); // a == b - a = A(3); - b = B(3); + value_a = 3; + value_b = 3; + a = A(value_a); + b = B(value_b); assert ( (a == b)); assert (!(a != b)); assert (!(a < b));