]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Fix -Wnarrowing in <complex> [PR116991]
authorJonathan Wakely <jwakely@redhat.com>
Mon, 7 Oct 2024 09:19:29 +0000 (10:19 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Wed, 9 Oct 2024 12:41:06 +0000 (13:41 +0100)
When _GLIBCXX_USE_C99_COMPLEX_ARC is undefined we use the generic
__complex_acos function template for _Float32 etc. and that gives a
-Wnarrowing warning:

complex:2043: warning: ISO C++ does not allow converting to '_Float32' from 'long double' with greater conversion rank [-Wnarrowing]

Use a cast to do the conversion so that it doesn't warn.

libstdc++-v3/ChangeLog:

PR libstdc++/116991
* include/std/complex (__complex_acos): Cast literal to
destination type.

libstdc++-v3/include/std/complex

index 5bc6618f7de0a4404ba958e24bd8f2461abfdf52..eb89e3a8bcfba5fdb696e3ebf22babdae8143d7c 100644 (file)
@@ -2040,7 +2040,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     __complex_acos(const std::complex<_Tp>& __z)
     {
       const std::complex<_Tp> __t = std::asin(__z);
-      const _Tp __pi_2 = 1.5707963267948966192313216916397514L;
+      const _Tp __pi_2 = (_Tp) 1.5707963267948966192313216916397514L;
       return std::complex<_Tp>(__pi_2 - __t.real(), -__t.imag());
     }