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 <lh_mouse@126.com>
diff --git a/mingw-w64-crt/stdio/mingw_pformat.c b/mingw-w64-crt/stdio/mingw_pformat.c
index 00e4b23..317dfe9 100644
--- a/mingw-w64-crt/stdio/mingw_pformat.c
+++ b/mingw-w64-crt/stdio/mingw_pformat.c
@@ -1495,7 +1495,10 @@
* 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.
*/