When `%.d` is passed an argument of 0, it should not produce any digits. The printf128 path uses an intermediate numeric string, which, in this case, shall be truncated to an empty string. Old code left least one digit so it erroneously produced "0".
This error was observed in one test in MPFR. Signed-off-by: LIU Hao <[email protected]> --- mingw-w64-crt/stdio/mingw_pformat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mingw-w64-crt/stdio/mingw_pformat.c b/mingw-w64-crt/stdio/mingw_pformat.c index 317dfe985..fc7429ba4 100644 --- a/mingw-w64-crt/stdio/mingw_pformat.c +++ b/mingw-w64-crt/stdio/mingw_pformat.c @@ -775,7 +775,7 @@ void __pformat_int( __pformat_intarg_t value, __pformat_t *stream ) */ __bigint_to_string(value.__pformat_u128_t.t128_2.digits32, 4, tmp_buff, bufflen); - __bigint_trim_leading_zeroes(tmp_buff,1); + __bigint_trim_leading_zeroes(tmp_buff, 0); memset(p,0,bufflen); for(int32_t i = strlen(tmp_buff) - 1; i >= 0; i--){ -- 2.52.0
From 83777d9993ec56e72e0cfbe6580b73956b1ed5b2 Mon Sep 17 00:00:00 2001 From: LIU Hao <[email protected]> Date: Thu, 27 Nov 2025 18:46:25 +0800 Subject: [PATCH] crt/stdio: Fix `%.d` output of printf128 for 0 When `%.d` is passed an argument of 0, it should not produce any digits. The printf128 path uses an intermediate numeric string, which, in this case, shall be truncated to an empty string. Old code left least one digit so it erroneously produced "0". This error was observed in one test in MPFR. Signed-off-by: LIU Hao <[email protected]> --- mingw-w64-crt/stdio/mingw_pformat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mingw-w64-crt/stdio/mingw_pformat.c b/mingw-w64-crt/stdio/mingw_pformat.c index 317dfe985..fc7429ba4 100644 --- a/mingw-w64-crt/stdio/mingw_pformat.c +++ b/mingw-w64-crt/stdio/mingw_pformat.c @@ -775,7 +775,7 @@ void __pformat_int( __pformat_intarg_t value, __pformat_t *stream ) */ __bigint_to_string(value.__pformat_u128_t.t128_2.digits32, 4, tmp_buff, bufflen); - __bigint_trim_leading_zeroes(tmp_buff,1); + __bigint_trim_leading_zeroes(tmp_buff, 0); memset(p,0,bufflen); for(int32_t i = strlen(tmp_buff) - 1; i >= 0; i--){ -- 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
