From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18381 invoked by alias); 8 May 2003 18:16:01 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 18358 invoked by uid 71); 8 May 2003 18:16:00 -0000 Resent-Date: 8 May 2003 18:16:00 -0000 Resent-Message-ID: <20030508181600.18357.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, Daniel.Levine@jhuapl.edu Received: (qmail 15270 invoked by uid 48); 8 May 2003 18:07:59 -0000 Message-Id: <20030508180759.15269.qmail@sources.redhat.com> Date: Thu, 08 May 2003 18:16:00 -0000 From: Daniel.Levine@jhuapl.edu Reply-To: Daniel.Levine@jhuapl.edu To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: libstdc++/10689: pow(std::complex(0),1/3) returns (nan, nan) instead of 0. X-SW-Source: 2003-05/txt/msg00636.txt.bz2 List-Id: >Number: 10689 >Category: libstdc++ >Synopsis: pow(std::complex(0),1/3) returns (nan, nan) instead of 0. >Confidential: no >Severity: non-critical >Priority: medium >Responsible: unassigned >State: open >Class: wrong-code >Submitter-Id: net >Arrival-Date: Thu May 08 18:16:00 UTC 2003 >Closed-Date: >Last-Modified: >Originator: Daniel Levine >Release: gcc 3.2-7 >Organization: >Environment: Any. >Description: Executing the pow(0,y) function call for doubles correctly produces return values of 0 as long as y != 0. Doing the same with the pow(std::complex(0),y) will return (nan, nan). This appears to be caused by the log(x) when x is 0 returning nan as it should. Further exp() will never return 0 so some check needs to be implemented so pow(std::complex(0),y) can return 0 when y != 0. This problem is not specific to complex. Other complex floating point types would suffer from the same problem. One final note, pow(std::complex(0), 1) works because it triggers other code while pow(std::complex(0), 1.0) fails. >How-To-Repeat: #include using namespace std; complex complexZero; complex cubeRootOf0 = pow(complexZero, 1.0/3.0); cerr << cubeRootof0 << endl; // Should be 0.0; complex zeroToThe1.0 = pow(complexZero, 1.0); cerr << zeroToThe1.0 << endl; // Should be 0.0; complex zeroToThe1 = pow(complexZero, 1); cerr << zeroToThe1 << endl; // Is 0.0; >Fix: >Release-Note: >Audit-Trail: >Unformatted: