Floating point comparisons with NaN values produce wrongresults

Mark Mitchell mark@codesourcery.com
Thu Sep 30 19:57:00 GMT 1999


>>>>> "Andi" == Andi Kleen <ak@muc.de> writes:

    Andi> moshier@mediaone.net (Stephen L Moshier) writes:

    >> > static const char double_q_nan_bytes_be[8] = {0x7f, 0xf8, 0,
    >> 0, 0, 0, 0, 0};
    >> 
    >> > #define double_q_nan (*(const double *)double_q_nan_bytes_be)
    >> 
    >> 
    >> This is not valid C language.  You need to fix your test case.

    Andi> Are you sure? char is allowd to alias with any type,
    Andi> including double. 

The relation is not symmetric.  You can use a char lvalue to access
anything.  You cannot use a double lvalue to access a bunch of chars.

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com



More information about the Gcc-bugs mailing list