From 040ee2028c724f132f0fd75f6d5333dc7d41305a Mon Sep 17 00:00:00 2001 From: wuyangfan <1102042793@qq.com> Date: Sun, 17 May 2026 22:52:20 +0800 Subject: [PATCH] Fix buffer size in write_significand for GCC 16 LTO Increase the stack buffer in the OutputIt overload from digits10() + 2 to + 3 so write_fixed cannot write past the end when significand_size reaches digits10 + 1, silencing -Wstringop-overflow under GCC 16 with LTO (fixes #4767). --- include/fmt/format.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index 256a99ab..fcd8b8f1 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -2452,8 +2452,8 @@ template OutputIt { - // Buffer is large enough to hold digits (digits10 + 1) and a decimal point. - Char buffer[digits10() + 2]; + // Buffer is large enough to hold digits (digits10 + 2) and a decimal point. + Char buffer[digits10() + 3]; auto end = write_significand(buffer, significand, significand_size, integral_size, decimal_point); return detail::copy_noinline(buffer, end, out);