From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4097A384A4B7; Wed, 17 May 2023 19:27:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4097A384A4B7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684351648; bh=q1/ImYvSwB9geo6tUEqSrL0fcpf1xujseSBNMb7JzBk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=IE1JxW1hy4Gm9lprCutqif4UHce18jSNT2dRxZDuwaoR+cD3twHvGLcf3ssvs6XoO 8FARJu3QZOZ/RrskXiHBYcBF66IrZCZLtCNQGXHgQ2VsEGov/I+gbgxdjr2PvI08jh 3h23oJ4gq7w5uIjt7PbqzbymsuJ/aqVIiKvzlSdU= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/109883] Stack Overflow in functions with types and -std=c++23 Date: Wed, 17 May 2023 19:27:28 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 13.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: jakub at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D109883 --- Comment #11 from CVS Commits --- The releases/gcc-13 branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:c42950e2d380d0da26203fb1eb39497c0a400b2d commit r13-7341-gc42950e2d380d0da26203fb1eb39497c0a400b2d Author: Jakub Jelinek Date: Wed May 17 21:21:23 2023 +0200 libstdc++: Fix up some templates [PR109883] As can be seen on the following testcase, for =20=20=20 std::{atan2,fmod,pow,copysign,fdim,fmax,fmin,hypot,nextafter,remainder,remq= uo,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 recurs= ion. This is because of a declaration ordering problem in , 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 f= ile, 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 bod= ies. 2023-05-17 Jakub Jelinek PR libstdc++/109883 * include/c_global/cmath (atan2, fmod, pow): Move __gnu_cxx::__promote_2 using templates after _Float{16,32,64,12= 8} and __gnu_cxx::__bfloat16_t overloads. (copysign, fdim, fmax, fmin, hypot, nextafter, remainder, remqu= o): 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: N= ew test. (cherry picked from commit 883f1e25dc7907c9bb37f480b900336a050218f1)=