Previously, `__pformat_emit_efloat()` initialized only its lower 8 bytes. If the CRT was configured with `--enable-experimental=printf128`, the higher 8 bytes were indeterminate.
This error was observed in one of GCC's self tests, where something such as
`printf("%g\n", (float)123456789);` gave incorrect results like
`1.23457e+773810688247020537949736540986933256`.
Signed-off-by: LIU Hao <[email protected]>
---
mingw-w64-crt/stdio/mingw_pformat.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/mingw-w64-crt/stdio/mingw_pformat.c
b/mingw-w64-crt/stdio/mingw_pformat.c
index 00e4b2359..317dfe985 100644
--- a/mingw-w64-crt/stdio/mingw_pformat.c
+++ b/mingw-w64-crt/stdio/mingw_pformat.c
@@ -1495,7 +1495,10 @@ void __pformat_emit_efloat( int sign, char *value, int
e, __pformat_t *stream )
* include the following exponent).
*/
int exp_width = 1;
- __pformat_intarg_t exponent; exponent.__pformat_llong_t = e -= 1;
+ __pformat_intarg_t exponent;
+ e -= 1;
+ exponent.__pformat_u128_t.t128.digits[1] = e < 0 ? -1 : 0;
+ exponent.__pformat_u128_t.t128.digits[0] = e;
/* Determine how many digit positions are required for the exponent.
*/
--
2.52.0
From 59830ec1d93be038ffe883b69229753bb18ff59e Mon Sep 17 00:00:00 2001 From: LIU Hao <[email protected]> Date: Wed, 26 Nov 2025 13:35:02 +0800 Subject: [PATCH 8002/8002] crt/stdio: Ensure `__pformat_intarg_t exponent` is fully initialized Previously, `__pformat_emit_efloat()` initialized only its lower 8 bytes. If the CRT was configured with `--enable-experimental=printf128`, the higher 8 bytes were indeterminate. This error was observed in one of GCC's self tests, where something such as `printf("%g\n", (float)123456789);` gave incorrect results like `1.23457e+773810688247020537949736540986933256`. Signed-off-by: LIU Hao <[email protected]> --- mingw-w64-crt/stdio/mingw_pformat.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mingw-w64-crt/stdio/mingw_pformat.c b/mingw-w64-crt/stdio/mingw_pformat.c index 00e4b2359..317dfe985 100644 --- a/mingw-w64-crt/stdio/mingw_pformat.c +++ b/mingw-w64-crt/stdio/mingw_pformat.c @@ -1495,7 +1495,10 @@ void __pformat_emit_efloat( int sign, char *value, int e, __pformat_t *stream ) * include the following exponent). */ int exp_width = 1; - __pformat_intarg_t exponent; exponent.__pformat_llong_t = e -= 1; + __pformat_intarg_t exponent; + e -= 1; + exponent.__pformat_u128_t.t128.digits[1] = e < 0 ? -1 : 0; + exponent.__pformat_u128_t.t128.digits[0] = e; /* Determine how many digit positions are required for the exponent. */ -- 2.52.0
OpenPGP_signature.asc
Description: OpenPGP digital signature
_______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
