------- Comment #11 from sgk at troutmask dot apl dot washington dot edu  
2009-06-01 19:16 -------
Subject: Re:  Complex division by zero in gfortran returns wrong results

On Mon, Jun 01, 2009 at 06:14:52PM -0000, ghazi at gcc dot gnu dot org wrote:
> 
> ----- Comment #10 from ghazi at gcc dot gnu dot org  2009-06-01 18:14 -------
> (In reply to comment #9)
> > If MPC returns inf or (inf + i inf) and the MPC developers do not consider
> > this to be a bug in their library, then gfortran will need to handle the
> > division by zero during constant folding as a special case.
> 
> I believe the goals for MPC are to follow C99 rules for special cases.
> Thus the return value of (inf + i inf) is intentional for MPC and not
> a bug in their thinking.
> 
> I entirely agree that the compile-time and runtime results should be
> identical.  If it is your intention to preserve the existing runtime
> behavior, then we should do the same in the fortran folder and special
> case this if/when converting complex division to use MPC.

Oh yuck.  I just checked n1124.pdf  In Annex G.5.1, it explicitly
defines this behavior:
   "if the first operand is a nonzero finite number or an infinity
    and the second operand is a zero, then the result of the / operator
    is an infinity."

Combining this with G.3:
   "A complex or imaginary value is a zero if each of its parts is a zero."

What is disturbing is Example 2 in G.5.1 on page 470!  Does gcc's runtime
implementation of complex division mirror Example 2?  I can understand
the need to avoid under/overflow, but _Cdivd() seems overly complicated.   

> Does this mean this PR should be closed as "invalid" ?

I think we should leave it open, perhaps in a suspended state, 
as a reminder (to me) that soemthing needs to be done with
gfortran an z/(0,0).


-- 


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

Reply via email to