From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13993 invoked by alias); 16 Jan 2007 10:22:40 -0000 Received: (qmail 13945 invoked by uid 48); 16 Jan 2007 10:22:22 -0000 Date: Tue, 16 Jan 2007 10:22:00 -0000 Subject: [Bug libstdc++/30482] New: division by 0 X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "jakub at gcc dot gnu dot org" 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: 2007-01/txt/msg01288.txt.bz2 http://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=221319 raises a question whether: std::complex (1.0, 1.0) / 0.0 and std::complex (1.0, 1.0) / std::complex (0.0, 0.0) can or can't be NaN. In C say: #define I (__extension__ 1.0iF) _Complex double d = 1.0 + 0.0 * I, e, f, z = 0.0 + 0.0 * I; int main (void) { e = d / 0.0; f = d / z; __builtin_printf ("%g %g %g %g\n", __real__ e, __imag__ e, __real__ f, __imag__ f); return 0; } in -std=c99 always prints inf (where complex inf is even when just one of the parts is inf), no matter what optimization options, in C89 the first division when optimizing is usually optimized into the simpler __real__ d / 0.0, __imag__ d / 0.0 division and thus gives inf too, but the latter and when not optimizing even the first one gives NaN. What do we want in C++? C++ doesn't use flag_complex_method = 2, so unless that changes, only the division by double (rather than std::complex ) could generally (when not optimizing) return inf - with a help in the specialization, see the above URL. -- Summary: division by 0 Product: gcc Version: 4.1.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: jakub at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30482