[PATCH] libstdc++: Define __promoted_t alias for C++17 without fold expressions [PR121097]
Tomasz Kaminski
tkaminsk@redhat.com
Wed Jul 16 06:16:55 GMT 2025
On Tue, Jul 15, 2025 at 10:36 PM Jonathan Wakely <jwakely@redhat.com> wrote:
> Define a fallback implementation of the __promoted_t alias for
> hypothetical C++17 compilers which don't define __cpp_fold_expressions.
> Without this, <cmath> can't be compiled by such compilers, because the
> 3-arg form of std::hypot uses the alias.
>
> libstdc++-v3/ChangeLog:
>
> PR libstdc++/121097
> * include/ext/type_traits.h (__promoted_t): Define fallback
> implementation for the 3-arg case that std::hypot uses.
> ---
>
> I tested this by bodging the header so that this definition is used
> unconditionally, and it seemed to work.
>
I do not understand why we are defining the promote_t alias, instead
of just changing the std::hypot to use __promoted_3, that is provided
also in case when __promoted is defined. Like fma does.
>
> libstdc++-v3/include/ext/type_traits.h | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/libstdc++-v3/include/ext/type_traits.h
> b/libstdc++-v3/include/ext/type_traits.h
> index 061555231468..ca5bc4e0d23e 100644
> --- a/libstdc++-v3/include/ext/type_traits.h
> +++ b/libstdc++-v3/include/ext/type_traits.h
> @@ -269,6 +269,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> {
> typedef __typeof__(_Tp2() + _Up2() + _Vp2() + _Wp2()) __type;
> };
> +
> +#ifdef __glibcxx_hypot // C++ >= 17 && HOSTED
> + // __promoted_t is needed by the 3-arg std::hypot so define this in case
> + // any C++17 compiler doesn't define __cpp_fold_expressions (PR 121097).
> + template<typename _Tp1, typename _Tp2, typename _Tp3>
> + using __promoted_t = typename __promote_3<_Tp1, _Tp2, _Tp3>::__type;
> +#endif
> +
> #endif
>
> _GLIBCXX_END_NAMESPACE_VERSION
> --
> 2.50.1
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://gcc.gnu.org/pipermail/libstdc++/attachments/20250716/6b54cc56/attachment.htm>
More information about the Libstdc++
mailing list