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 )
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.)

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

In reply to Re^5: [Win32, C, and way OT] C floats, doubles, and their equivalence by syphilis
in thread [Win32, C, and way OT] C floats, doubles, and their equivalence by syphilis

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.