From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21804 invoked by alias); 26 Apr 2011 14:32:46 -0000 Received: (qmail 21795 invoked by uid 22791); 26 Apr 2011 14:32:46 -0000 X-SWARE-Spam-Status: No, hits=-2.7 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 26 Apr 2011 14:32:32 +0000 From: "joseph at codesourcery dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/48760] [4.6 / 4.7 Regression (?)] std::complex constructor buggy in the face of NaN's X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: joseph at codesourcery dot com X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: paolo.carlini at oracle dot com X-Bugzilla-Target-Milestone: 4.6.1 X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Tue, 26 Apr 2011 14:32:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-04/txt/msg02635.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48760 --- Comment #15 from 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).