public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/107538] New: std::pow(10, std::complex(NaN, 1)) aborts with -D_GLIBCXX_ASSERTIONS
Date: Sat, 05 Nov 2022 21:37:05 +0000	[thread overview]
Message-ID: <bug-107538-4@http.gcc.gnu.org/bugzilla/> (raw)

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	other threads:[~2022-11-05 21:37 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-05 21:37 redi at gcc dot gnu.org [this message]
2022-11-05 21:37 ` [Bug libstdc++/107538] " redi at gcc dot gnu.org
2022-11-05 21:45 ` redi at gcc dot gnu.org
2022-11-09  4:38 ` redi at gcc dot gnu.org
2022-11-09 13:29 ` redi at gcc dot gnu.org
2023-04-26  6:56 ` rguenth at gcc dot gnu.org
2023-07-27  9:24 ` rguenth at gcc dot gnu.org
2024-02-13  4:11 ` orion at nwra dot com
2024-05-21  9:12 ` jakub at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-107538-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).