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

            Bug ID: 107538
           Summary: std::pow(10, std::complex(NaN, 1)) aborts with
                    -D_GLIBCXX_ASSERTIONS
           Product: gcc
           Version: 12.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

#define _GLIBCXX_ASSERTIONS
#include <complex>
#include <limits>

int main()
{
  double nan = std::numeric_limits<double>::quiet_NaN();
  std::pow(10, std::complex<double>(nan, 1));
}


/usr/include/c++/12/complex:703: std::complex<_Tp> std::polar(const _Tp&, const
_Tp&) [with _Tp = double]: Assertion '__rho >= 0' failed.
Aborted (core dumped)


The standard says that pow(x,y) should be exp(y * log(x)) so by using
std::polar we introduce a precondition that shouldn't be there.

Reply via email to