public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/19138] New: double complex / inf gives nan instead of 0
@ 2004-12-23 14:35 dmitri at unm dot edu
  2004-12-23 14:41 ` [Bug middle-end/19138] " pinskia at gcc dot gnu dot org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: dmitri at unm dot edu @ 2004-12-23 14:35 UTC (permalink / raw)
  To: gcc-bugs

The following program gives "nan nan" output instead of expected "0 0"
#include <stdio.h>

_Complex double a, r;
double b = 1.0 / 0.0;

int
main (void)
{
  __real__ a = 1.0;
  __imag__ a = -1.0;
  r = a / b;
  printf ("%f %f\n", __real__ r, __imag__ r);
  return 0;
}


As alois.schloegl@tugraz.at pointed out
<<<<
Prof. W .Kahan mentions in his "Lecture Notes on the Status of IEEE
754" p.10
http://www.cs.berkeley.edu/~wkahan/ieee754status/IEEE754.PDF

"when (0+3i)/inf is turned naively into (0+3i)*(inf-i)/(inf^2+0^2) it
generates
a NaN instead of the expected 0."
>>>>

This may be of some relevance here.

-- 
           Summary: double complex / inf gives nan instead of 0
           Product: gcc
           Version: 3.2.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dmitri at unm dot edu
                CC: gcc-bugs at gcc dot gnu dot org,jakub at redhat dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19138


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug middle-end/19138] double complex / inf gives nan instead of 0
  2004-12-23 14:35 [Bug c/19138] New: double complex / inf gives nan instead of 0 dmitri at unm dot edu
@ 2004-12-23 14:41 ` pinskia at gcc dot gnu dot org
  2004-12-23 14:43 ` dmitri at unm dot edu
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-12-23 14:41 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-12-23 14:41 -------
I don't see anything wrong with this.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c                           |middle-end


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19138


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug middle-end/19138] double complex / inf gives nan instead of 0
  2004-12-23 14:35 [Bug c/19138] New: double complex / inf gives nan instead of 0 dmitri at unm dot edu
  2004-12-23 14:41 ` [Bug middle-end/19138] " pinskia at gcc dot gnu dot org
@ 2004-12-23 14:43 ` dmitri at unm dot edu
  2004-12-23 15:18 ` dmitri at unm dot edu
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: dmitri at unm dot edu @ 2004-12-23 14:43 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From dmitri at unm dot edu  2004-12-23 14:43 -------
I do not understand. "nan" is not "0". That seems to be the problem.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19138


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug middle-end/19138] double complex / inf gives nan instead of 0
  2004-12-23 14:35 [Bug c/19138] New: double complex / inf gives nan instead of 0 dmitri at unm dot edu
  2004-12-23 14:41 ` [Bug middle-end/19138] " pinskia at gcc dot gnu dot org
  2004-12-23 14:43 ` dmitri at unm dot edu
@ 2004-12-23 15:18 ` dmitri at unm dot edu
  2004-12-23 15:50 ` joseph at codesourcery dot com
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: dmitri at unm dot edu @ 2004-12-23 15:18 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From dmitri at unm dot edu  2004-12-23 15:18 -------
I noticed that my attempt to do multiple selection of gcc version did not quite
work. I see this bug with gcc 3.2.2, 3.3.3 and as late as 3.4.3 20041212 (Red
Hat 3.4.3-10).


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19138


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug middle-end/19138] double complex / inf gives nan instead of 0
  2004-12-23 14:35 [Bug c/19138] New: double complex / inf gives nan instead of 0 dmitri at unm dot edu
                   ` (2 preceding siblings ...)
  2004-12-23 15:18 ` dmitri at unm dot edu
@ 2004-12-23 15:50 ` joseph at codesourcery dot com
  2004-12-23 17:14 ` bangerth at dealii dot org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: joseph at codesourcery dot com @ 2004-12-23 15:50 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From joseph at codesourcery dot com  2004-12-23 15:50 -------
Subject: Re:  New: double complex / inf gives nan instead of 0

On Thu, 23 Dec 2004, dmitri at unm dot edu wrote:

> The following program gives "nan nan" output instead of expected "0 0"

It would have been helpful to point to C99 G.5.1 paragraph 4 third bullet 
point as the source of your expectation.  We don't yet implement the C99 
requirements for complex numbers (either the normative ones, or the 
non-normative ones in Annex G), though it would be useful to do so.



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19138


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug middle-end/19138] double complex / inf gives nan instead of 0
  2004-12-23 14:35 [Bug c/19138] New: double complex / inf gives nan instead of 0 dmitri at unm dot edu
                   ` (3 preceding siblings ...)
  2004-12-23 15:50 ` joseph at codesourcery dot com
@ 2004-12-23 17:14 ` bangerth at dealii dot org
  2004-12-23 19:20 ` pcarlini at suse dot de
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: bangerth at dealii dot org @ 2004-12-23 17:14 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-12-23 17:14 -------
Joseph's comment points to the exact right place. The result should be zero. 
Confirmed with gcc 3.3 and mainline. 
W. 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
      Known to fail|                            |3.3.1 4.0.0
   Last reconfirmed|0000-00-00 00:00:00         |2004-12-23 17:14:40
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19138


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug middle-end/19138] double complex / inf gives nan instead of 0
  2004-12-23 14:35 [Bug c/19138] New: double complex / inf gives nan instead of 0 dmitri at unm dot edu
                   ` (4 preceding siblings ...)
  2004-12-23 17:14 ` bangerth at dealii dot org
@ 2004-12-23 19:20 ` pcarlini at suse dot de
  2004-12-23 23:06 ` bangerth at dealii dot org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pcarlini at suse dot de @ 2004-12-23 19:20 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pcarlini at suse dot de  2004-12-23 19:20 -------
I'm tempted to mark this as duplicate of middle-end/18902, which I will try to
(partially) fix after 4.0 branches. Ok with everyone?

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19138


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug middle-end/19138] double complex / inf gives nan instead of 0
  2004-12-23 14:35 [Bug c/19138] New: double complex / inf gives nan instead of 0 dmitri at unm dot edu
                   ` (5 preceding siblings ...)
  2004-12-23 19:20 ` pcarlini at suse dot de
@ 2004-12-23 23:06 ` bangerth at dealii dot org
  2004-12-23 23:17 ` pcarlini at suse dot de
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: bangerth at dealii dot org @ 2004-12-23 23:06 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-12-23 23:06 -------
This PR only covers a special case of the other PR, so I would be tempted 
to keep both open and if the other one is fixed checked whether this also 
covers the special case discussed here. I'm not sure whether this special 
case here immediately follows from fixing PR 18902. 
 
W. 

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19138


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug middle-end/19138] double complex / inf gives nan instead of 0
  2004-12-23 14:35 [Bug c/19138] New: double complex / inf gives nan instead of 0 dmitri at unm dot edu
                   ` (6 preceding siblings ...)
  2004-12-23 23:06 ` bangerth at dealii dot org
@ 2004-12-23 23:17 ` pcarlini at suse dot de
  2004-12-23 23:19 ` bangerth at dealii dot org
  2004-12-23 23:22 ` pcarlini at suse dot de
  9 siblings, 0 replies; 11+ messages in thread
From: pcarlini at suse dot de @ 2004-12-23 23:17 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pcarlini at suse dot de  2004-12-23 23:17 -------
>                                           I'm not sure whether this special 
> case here immediately follows from fixing PR 18902.

It does, indeed, this one is a *really* a special case: have a look to the test
case that I have attached to 18902 (and verified fixed by a preliminary patch ;)
But, if we want to keep both open, it's ok with me!


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19138


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug middle-end/19138] double complex / inf gives nan instead of 0
  2004-12-23 14:35 [Bug c/19138] New: double complex / inf gives nan instead of 0 dmitri at unm dot edu
                   ` (7 preceding siblings ...)
  2004-12-23 23:17 ` pcarlini at suse dot de
@ 2004-12-23 23:19 ` bangerth at dealii dot org
  2004-12-23 23:22 ` pcarlini at suse dot de
  9 siblings, 0 replies; 11+ messages in thread
From: bangerth at dealii dot org @ 2004-12-23 23:19 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-12-23 23:19 -------
I'll be happy to defer to your superior technical knowledge :-) 
W. 

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19138


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug middle-end/19138] double complex / inf gives nan instead of 0
  2004-12-23 14:35 [Bug c/19138] New: double complex / inf gives nan instead of 0 dmitri at unm dot edu
                   ` (8 preceding siblings ...)
  2004-12-23 23:19 ` bangerth at dealii dot org
@ 2004-12-23 23:22 ` pcarlini at suse dot de
  9 siblings, 0 replies; 11+ messages in thread
From: pcarlini at suse dot de @ 2004-12-23 23:22 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pcarlini at suse dot de  2004-12-23 23:22 -------
Ok ;) Then, let's close this one.

*** This bug has been marked as a duplicate of 18902 ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19138


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2004-12-23 23:22 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-23 14:35 [Bug c/19138] New: double complex / inf gives nan instead of 0 dmitri at unm dot edu
2004-12-23 14:41 ` [Bug middle-end/19138] " pinskia at gcc dot gnu dot org
2004-12-23 14:43 ` dmitri at unm dot edu
2004-12-23 15:18 ` dmitri at unm dot edu
2004-12-23 15:50 ` joseph at codesourcery dot com
2004-12-23 17:14 ` bangerth at dealii dot org
2004-12-23 19:20 ` pcarlini at suse dot de
2004-12-23 23:06 ` bangerth at dealii dot org
2004-12-23 23:17 ` pcarlini at suse dot de
2004-12-23 23:19 ` bangerth at dealii dot org
2004-12-23 23:22 ` pcarlini at suse dot de

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).