public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: Andrew Pinski <pinskia@gmail.com>
To: "gcc-bugzilla@gcc.gnu.org" <gcc-bugzilla@gcc.gnu.org>
Cc: "gcc-bugs@gcc.gnu.org" <gcc-bugs@gcc.gnu.org>
Subject: Re: [Bug c/44741]  New: Complex division with NaN produces unexpected result
Date: Thu, 01 Jul 2010 05:04:00 -0000	[thread overview]
Message-ID: <145BE320-BF06-4ACB-B7B2-6EE8F7C31395@gmail.com> (raw)
In-Reply-To: <bug-44741-1313@http.gcc.gnu.org/bugzilla/>

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" <gcc-bugzilla@gcc.gnu.org 
 > 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 <stdio.h>
> #include <math.h>
> #include <complex.h>
>
> __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
>


  parent reply	other threads:[~2010-07-01  5:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-01  4:52 ian at airs dot com
2010-07-01  5:04 ` [Bug c/44741] " pinskia at gmail dot com
2010-07-01  5:04 ` Andrew Pinski [this message]
2010-07-01 10:51 ` paolo dot carlini at oracle dot com
2010-07-02  0:36 ` pinskia at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=145BE320-BF06-4ACB-B7B2-6EE8F7C31395@gmail.com \
    --to=pinskia@gmail.com \
    --cc=gcc-bugs@gcc.gnu.org \
    --cc=gcc-bugzilla@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).