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.
This commit is contained in:
Laurent Rineau 2011-03-01 16:54:21 +00:00
parent 7e8cf96017
commit 942a071374
1 changed files with 15 additions and 2 deletions

View File

@ -46,8 +46,21 @@ void test_implicit_interoperable_for_real_embeddable (CGAL::Tag_false){}
template <typename A, typename B>
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