https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117805

--- Comment #20 from mjr19 at cam dot ac.uk ---
I am not convinced that gfortran's current behaviour is wholly consistent with
what a mathematician would reasonably expect. When I was taught complex
arithmetic, multiplication by one and addition of zero were both identity
operations. But in gfortran they can move one across a branch cut.

program test
  print *,sqrt(-(1.0,0.0))       ! Below branch cut
  print *,sqrt(-(1.0,-0.0))      ! Above branch cut
  print *,sqrt(-(1*(1.0,-0.0)))  ! Now below branch cut

  print *,sqrt((-1.0,-0.0))      ! Below branch cut
  print *,sqrt((-1.0,-0.0)+0)    ! Now above branch cut
end program test

I don't think it is possible to produce rules for complex arithmetic based on a
Cartesian representation with signed zeros which do not produce surprises
similar to the above.

Reply via email to