public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/109883] Stack Overflow in <cmath> functions with <stdfloat> types and -std=c++23 Date: Wed, 17 May 2023 19:22:08 +0000 [thread overview] Message-ID: <bug-109883-4-b4bxFKaylU@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-109883-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109883 --- Comment #10 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>: https://gcc.gnu.org/g:883f1e25dc7907c9bb37f480b900336a050218f1 commit r14-949-g883f1e25dc7907c9bb37f480b900336a050218f1 Author: Jakub Jelinek <jakub@redhat.com> Date: Wed May 17 21:21:23 2023 +0200 libstdc++: Fix up some <cmath> templates [PR109883] As can be seen on the following testcase, for std::{atan2,fmod,pow,copysign,fdim,fmax,fmin,hypot,nextafter,remainder,remquo,fma} if one operand type is std::float{16,32,64,128}_t or std::bfloat16_t and another one some integral type or some other floating point type which promotes to the other operand's type, we can end up with endless recursion. This is because of a declaration ordering problem in <cmath>, where the float, double and long double overloads of those functions come before the templates which use __gnu_cxx::__promote_{2,3}, but the std::float{16,32,64,128}_t and std::bfloat16_t overloads come later in the file. If the result of those promotions is _Float{16,32,64,128} or __gnu_cxx::__bfloat16_t, say std::pow(_Float64, int) calls std::pow(_Float64, _Float64) and the latter calls itself. The following patch fixes that by moving those templates later in the file, so that the calls from those templates see also the other overloads. I think other templates in the file like e.g. isgreater etc. shouldn't be a problem, because those just use __builtin_isgreater etc. in their bodies. 2023-05-17 Jakub Jelinek <jakub@redhat.com> PR libstdc++/109883 * include/c_global/cmath (atan2, fmod, pow): Move __gnu_cxx::__promote_2 using templates after _Float{16,32,64,128} and __gnu_cxx::__bfloat16_t overloads. (copysign, fdim, fmax, fmin, hypot, nextafter, remainder, remquo): Likewise. (fma): Move __gnu_cxx::__promote_3 using template after _Float{16,32,64,128} and __gnu_cxx::__bfloat16_t overloads. * testsuite/26_numerics/headers/cmath/constexpr_std_c++23.cc: New test.
next prev parent reply other threads:[~2023-05-17 19:22 UTC|newest] Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-05-17 6:39 [Bug c++/109883] New: Stack Overflow in <cmath> functions with <stdfloat> types matt at mattborland dot com 2023-05-17 10:12 ` [Bug libstdc++/109883] " xry111 at gcc dot gnu.org 2023-05-17 10:12 ` xry111 at gcc dot gnu.org 2023-05-17 12:29 ` matt at mattborland dot com 2023-05-17 12:33 ` [Bug libstdc++/109883] Stack Overflow in <cmath> functions with <stdfloat> types and -std=c++23 xry111 at gcc dot gnu.org 2023-05-17 12:35 ` xry111 at gcc dot gnu.org 2023-05-17 12:40 ` xry111 at gcc dot gnu.org 2023-05-17 12:41 ` matt at mattborland dot com 2023-05-17 12:56 ` jakub at gcc dot gnu.org 2023-05-17 13:28 ` jakub at gcc dot gnu.org 2023-05-17 14:24 ` jakub at gcc dot gnu.org 2023-05-17 19:22 ` cvs-commit at gcc dot gnu.org [this message] 2023-05-17 19:27 ` cvs-commit at gcc dot gnu.org 2023-05-17 19:29 ` jakub at gcc dot gnu.org 2023-05-18 3:22 ` xry111 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-109883-4-b4bxFKaylU@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: linkBe 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).