Jakub Jelinek c42950e2d3 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.

(cherry picked from commit 883f1e25dc7907c9bb37f480b900336a050218f1)
2023-05-17 21:27:04 +02:00
2023-04-27 00:21:18 +00:00
2023-04-27 00:21:18 +00:00
2023-05-10 00:22:50 +00:00
2023-05-07 00:21:31 +00:00
2023-05-17 00:20:59 +00:00
2023-05-11 09:19:00 -07:00
2023-05-17 00:20:59 +00:00
2022-07-19 17:07:04 +03:00

This directory contains the GNU Compiler Collection (GCC).

The GNU Compiler Collection is free software.  See the files whose
names start with COPYING for copying permission.  The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.

The directory INSTALL contains copies of the installation information
as HTML and plain text.  The source of this information is
gcc/doc/install.texi.  The installation information includes details
of what is included in the GCC sources and what files GCC installs.

See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information.  An online readable
version of the manual is in the files gcc/doc/gcc.info*.

See http://gcc.gnu.org/bugs/ for how to report bugs usefully.

Copyright years on GCC source files may be listed using range
notation, e.g., 1987-2012, indicating that every year in the range,
inclusive, is a copyrightable year that could otherwise be listed
individually.
S
Description
Yggdrasil port of the GNU Compiler Collection
Readme 978 MiB
Languages
C++ 33%
C 27.4%
Ada 13%
Go 7.1%
D 7%
Other 12.1%