http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48760
--- Comment #15 from joseph at codesourcery dot com <joseph at codesourcery dot com> 2011-04-26 14:30:50 UTC --- On Mon, 25 Apr 2011, john at johnmaddock dot co.uk wrote: > Sorry to be dumb, but doesn't the result of the C code violate section G.5.2 > in > C99 - which is to say that no matter what the value of the imaginary part of > an > expression, it never changes the real part - even if that is a NaN? I can't make any sense of that sentence - what is the "it" you are saying is changing a real part but shouldn't be? In NaN * 1.0fi, the first operand is real and the second is complex (*not* imaginary, GCC doesn't have imaginary types), so the real part of the result is NaN*0 which is NaN and the imaginary part is NaN*1 which is also NaN. Adding 0 then results in a real part of 0+NaN, which is NaN, and an imaginary part of NaN. This is in accordance with how mixed real/complex arithmetic works in C99 - implemented for C in 4.5 and I think for C++ in 4.6 (with associated removal of bogus optimizations that tried to treat values of complex type as being real or imaginary values if one part was zero). The built-in function semantics would be those of CMPLXF, CMPLX and CMPLXL in 7.3.9.3 in the C1X DIS (N1569).