https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107753
--- Comment #6 from Steve Kargl <sgk at troutmask dot apl.washington.edu> --- On Fri, Nov 18, 2022 at 11:24:29PM +0000, sgk at troutmask dot apl.washington.edu wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107753 > > --- Comment #5 from Steve Kargl <sgk at troutmask dot apl.washington.edu> --- > On Fri, Nov 18, 2022 at 10:05:21PM +0000, kargl at gcc dot gnu.org wrote: > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107753 > > > > --- Comment #4 from kargl at gcc dot gnu.org --- > > (In reply to anlauf from comment #3) > > > I guess the reporter assumes that gcc uses a clever algorithm like Smith's > > > to handle such extreme cases of complex division. Not sure if that one is > > > available by some compilation flag, and I think it would impact > > > performance. > > > > > > In any case, if the reporter wants to get robust results and in a portable > > > way, I would advise him to change/fix his algorithm accordingly. It > > > appears > > > that a few other compilers behave here like gfortran. > > > > It's likely coming from the middle-end where gcc.info has > > the option > > > > '-fcx-fortran-rules' > > Complex multiplication and division follow Fortran rules. Range > > reduction is done as part of complex division, but there is no > > checking whether the result of a complex multiplication or division > > is 'NaN + I*NaN', with an attempt to rescue the situation in that > > case. > > Does anyone know what is meant by "Fortran rules"? F66 does not > have any particular algorithm specified. I'll look at F77 shortly. > I add the subroutine subroutine ohno complex(dp), parameter :: a = cmplx(huge(1.d0),huge(1.d0),dp) complex(dp), parameter :: b = a / a write(*,*) a write(*,*) b end subroutine ohno % gfortran -o z a.f90 && ./z (1.79769313486231571E+308,1.79769313486231571E+308) (NaN,0.0000000000000000) (1.79769313486231571E+308,1.79769313486231571E+308) (1.0000000000000000,0.0000000000000000) The last two lines are from ohno.