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

            Bug ID: 77858
           Summary: std::polar throws an exception if rho is negative
           Product: gcc
           Version: 6.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: holger.seelig at yahoo dot de
  Target Milestone: ---

I think it is not right to throw an exception if rho is negative. The result is
well defined for polar representation if rho is negative if polar is something
like this:

real = rho * cos (theta);
imag = rho * sin (theta);

then:

-polar (abs (r), t) == polar (-abs (r), t)

It is in the responsibility of the programmer to check the input of those
function.

If std::polar throws an exception why does the calculation 1.0 / 0.0 not throw
an exception the result is not well defined in that case. Numbers like complex
are there to do calculations, and I can very nice do nice calculations with an
negative rho. If I cannot pass a negative rho then I cannot use complex numbers
in my caluclations. Should I now switch back to handle this with cos and sin
where std::polar was so elegant? Numbers are there to calculate something for
me but not now anymore std::complex. What a pity!

Reply via email to