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

UPDATE - this should be reaped. It's the slightly later post that was intended to be sent ... not this. (Not that there's a great deal of difference.)

No, no - all I was pointing out was that "volatile" was of no use to me - and I certainly don't mean to imply that you claimed it *would* be of any use to me. In the PDL source I've had to use #pragma optimize("", off) to get the desired behaviour. The conditional test that's causing all the problems in the autogenerated bad.xs is:
if((a_datap)[0] /* ACCESS() */ == (PDL_Float) __privtrans->value )
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:
PDL_Float dummy = (PDL_Float) __privtrans->value; if ( (a_datap)[0] /* ACCESS() */ == dummy )
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:
#pragma optimize("", off) PDL_Float dummy = (PDL_Float) __privtrans->value; if ( (a_datap)[0] /* ACCESS() */ == dummy )
Btw, in case there's a need to mention it, the PDL_Float type is typedef'd as follows:
typedef float PDL_Float;
Cheers,
Rob