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

--- Comment #18 from Ryo Furue <furue at hawaii dot edu> ---
(In reply to Steve Kargl from comment #17)

> >   real, parameter:: a = -1.0
> >   if (a > 0) write(*,*) sqrt(a)
> > 
> > With such a switch turned on, the compiler can replace sqrt(-1.0) with NaN 
> > and
> > let the code pass.
> > 
> 
> Why not replace it with 0 instead of NaN?

I think that would be another good choice.  I'm not insisting on NaN at all. 
sqrt(-1.0) is undefined within real numbers, so NaN is one valid choice.  But,
as you say, it's defined in complex numbers, so converting it to zero is
another valid choice.  A third valid choice is to convert it to complex number
(0.0,-1.0).  I'm not saying which is the most valid.  I just think NaN is the
most sensible choice NOW, if we disregard the history of the Fortran language.
(I guess the IEEE standard says that NaN is the result, but I'm not sure at
all.)

> Yeah, I get it.  You don't like the choice that gfortran
> made 10+ years ago.

Not quite.  Whether I like it or not doesn't matter.  All I'm saying is that
adding an option to convert those "invalid" numbers according to the IEEE rule
(or in the absence of the IEEE rule for particular conversions, to some
sensible numbers) and let the code pass would be a useful extension to gfortran
NOW.  Since it's a useful extension with little harm, that is a good addition
to gfortran to enhance its usefulness, I think.

Before signing off, I'd like to apologize for my submitting this as a "bug". 
Through this conversation, I quickly realized I was wrong in thinking it is a
bug.  I should have submitted it as a "wish", so that some of the developers
might consider it as a future extension.

Cheers,
Ryo

Reply via email to