in reply to Re^4: [Win32, C, and way OT] C floats, doubles, and their equivalence
in thread [Win32, C, and way OT] C floats, doubles, and their equivalence
where (a_datap)[0] is a float and __privtrans->value is a double. With all but the pre-VC8.0 compilers, that behaves as desired and expected. My initial attempt at a fix (from the replies received here) for the pre-VC8.0 compilers was to replace that with:if((a_datap)[0] /* ACCESS() */ == (PDL_Float) __privtrans->value )
All of the playing around that I've done with C scripts suggests that that should have worked ... but it didn't. I still got FALSE evaluations when I wanted and expected the evaluation to be TRUE. If I make 'dummy' volatile, that doesn't make any difference. One way I can get that modified code to behave correctly is to turn off optimization using #pragma. That is, for pre-VC8.0 MS compilers, the code (which behaves correctly) is:PDL_Float dummy = (PDL_Float) __privtrans->value; if ( (a_datap)[0] /* ACCESS() */ == dummy )
A patch that provides a better fix will always be most welcome. (It may be relevant that optimization is off for some of the other code as well - not just for the creation of the dummy variable and the testing of the == condition. The optimization cannot be turned on/off inside subroutines.)#pragma optimize("", off) PDL_Float dummy = (PDL_Float) __privtrans->value; if ( (a_datap)[0] /* ACCESS() */ == dummy )
Cheers,typedef float PDL_Float;
|
|---|