* [pushed] libstdc++: add casts to from_chars in <charconv> [PR111883]
@ 2023-10-20 16:34 Marek Polacek
0 siblings, 0 replies; only message in thread
From: Marek Polacek @ 2023-10-20 16:34 UTC (permalink / raw)
To: GCC Patches, libstdc++
Tested x86_64-pc-linux-gnu, applying to trunk.
-- >8 --
This fixes
.../charconv: In function 'std::from_chars_result std::from_chars(const char*, const char*, _Float16&, chars_format)':
.../charconv:687:17: warning: converting to '_Float16' from 'float' with greater conversion rank
687 | __value = __val;
| ^~~~~
.../charconv: In function 'std::from_chars_result std::from_chars(const char*, const char*, __gnu_cxx::__bfloat16_t&, chars_format)':
.../charconv:763:17: warning: converting to '__gnu_cxx::__bfloat16_t' {aka '__bf16'} from 'float' with greater conversion rank
763 | __value = __val;
| ^~~~~
which was breaking a test:
FAIL: g++.dg/warn/Wstringop-overflow-6.C -std=gnu++26 (test for excess errors)
libstdc++-v3/ChangeLog:
* include/std/charconv (from_chars): Add explicit casts.
---
libstdc++-v3/include/std/charconv | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/libstdc++-v3/include/std/charconv b/libstdc++-v3/include/std/charconv
index cb428fe6d3b..6cb7fecff87 100644
--- a/libstdc++-v3/include/std/charconv
+++ b/libstdc++-v3/include/std/charconv
@@ -684,7 +684,7 @@ namespace __detail
from_chars_result __res
= __from_chars_float16_t(__first, __last, __val, __fmt);
if (__res.ec == errc{})
- __value = __val;
+ __value = _Float16(__val);
return __res;
}
#endif
@@ -697,7 +697,7 @@ namespace __detail
float __val;
from_chars_result __res = from_chars(__first, __last, __val, __fmt);
if (__res.ec == errc{})
- __value = __val;
+ __value = _Float32(__val);
return __res;
}
#endif
@@ -710,7 +710,7 @@ namespace __detail
double __val;
from_chars_result __res = from_chars(__first, __last, __val, __fmt);
if (__res.ec == errc{})
- __value = __val;
+ __value = _Float64(__val);
return __res;
}
#endif
@@ -723,7 +723,7 @@ namespace __detail
long double __val;
from_chars_result __res = from_chars(__first, __last, __val, __fmt);
if (__res.ec == errc{})
- __value = __val;
+ __value = _Float128(__val);
return __res;
}
#elif defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_HAVE_FLOAT128_MATH)
@@ -739,7 +739,7 @@ namespace __detail
__extension__ __ieee128 __val;
from_chars_result __res = from_chars(__first, __last, __val, __fmt);
if (__res.ec == errc{})
- __value = __val;
+ __value = _Float128(__val);
return __res;
}
#else
@@ -760,7 +760,7 @@ namespace __detail
from_chars_result __res
= __from_chars_bfloat16_t(__first, __last, __val, __fmt);
if (__res.ec == errc{})
- __value = __val;
+ __value = __gnu_cxx::__bfloat16_t(__val);
return __res;
}
#endif
base-commit: eb15fad3190a8b33e3e451b964ff1ecf08bbb113
--
2.41.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-10-20 16:34 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-20 16:34 [pushed] libstdc++: add casts to from_chars in <charconv> [PR111883] Marek Polacek
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).