From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23719 invoked by alias); 1 Jul 2010 05:04:03 -0000 Received: (qmail 23593 invoked by uid 22791); 1 Jul 2010 05:04:02 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from mail-px0-f175.google.com (HELO mail-px0-f175.google.com) (209.85.212.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 01 Jul 2010 05:03:56 +0000 Received: by pxi12 with SMTP id 12so721701pxi.20 for ; Wed, 30 Jun 2010 22:03:54 -0700 (PDT) Received: by 10.142.9.15 with SMTP id 15mr11500408wfi.235.1277960634609; Wed, 30 Jun 2010 22:03:54 -0700 (PDT) Received: from [10.11.170.140] ([166.205.136.190]) by mx.google.com with ESMTPS id l10sm6499015rvh.21.2010.06.30.22.03.52 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 30 Jun 2010 22:03:53 -0700 (PDT) References: Message-Id: <145BE320-BF06-4ACB-B7B2-6EE8F7C31395@gmail.com> From: Andrew Pinski To: "gcc-bugzilla@gcc.gnu.org" In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (iPhone Mail 7E18) Subject: Re: [Bug c/44741] New: Complex division with NaN produces unexpected result Date: Thu, 01 Jul 2010 05:04:00 -0000 Cc: "gcc-bugs@gcc.gnu.org" X-IsSubscribed: yes 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: 2010-07/txt/msg00009.txt.bz2 I think the issue is we don't implement imagainy types so 1 + nan I turns into nan. On Jun 30, 2010, at 9:51 PM, "ian at airs dot com" wrote: > Annex G of the ISO C99 standard says that a complex value with one > part being > infinity is considered an infinity, even if the other part is a > NaN. It's not > clearly stated, but presumably if neither part of the number is an > infinity, > but one part is a NaN, then the number is a NaN. And presumably if > a complex > NaN is involved in a math operation, the result should be a complex > NaN. > > So, I would expect that dividing a complex NaN by a complex 0 would > give me a > complex NaN. However, when I run this program: > > > #include > #include > #include > > __complex float > div (__complex float f1, __complex float f2) > { > return f1 / f2; > } > > int > main () > { > __complex float f; > > f = div (NAN + NAN * I, 0); > printf ("%g+%g*i\n", creal (f), cimag (f)); > f = div (1.0 + NAN * I, 0); > printf ("%g+%g*i\n", creal (f), cimag (f)); > f = div (NAN + 1.0 * I, 0); > printf ("%g+%g*i\n", creal (f), cimag (f)); > } > > with current mainline, it prints > > nan+nan*i > nan+nan*i > nan+inf*i > > That last answer seems incorrect according to the rules of Annex G. > It is an > infinity when it should be a NaN. > > > -- > Summary: Complex division with NaN produces unexpected > result > Product: gcc > Version: 4.6.0 > Status: UNCONFIRMED > Severity: normal > Priority: P3 > Component: c > AssignedTo: unassigned at gcc dot gnu dot org > ReportedBy: ian at airs dot com > > > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44741 >