[committed] libstdc++: Avoid warning in std::format

Message ID 20230719113829.2510208-1-jwakely@redhat.com
State Accepted
Headers
Series [committed] libstdc++: Avoid warning in std::format |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Jonathan Wakely July 19, 2023, 11:38 a.m. UTC
  Tested x86_64-linux. Pushed to trunk.

-- >8 --

With -Wmaybe-uninitialized -Wsystem-headers there's a warning about
creating a string_view from an uninitalized array. Initializing the
first element of the array avoids the warning.

libstdc++-v3/ChangeLog:

	* include/std/format (__write_padded): Initialize first element
	of array to avoid a -Wmaybe-uninitialized warning.
---
 libstdc++-v3/include/std/format | 1 +
 1 file changed, 1 insertion(+)
  

Patch

diff --git a/libstdc++-v3/include/std/format b/libstdc++-v3/include/std/format
index 9d5981e4882..9710bff3c03 100644
--- a/libstdc++-v3/include/std/format
+++ b/libstdc++-v3/include/std/format
@@ -610,6 +610,7 @@  namespace __format
     {
       const size_t __buflen = 0x20;
       _CharT __padding_chars[__buflen];
+      __padding_chars[0] = _CharT();
       basic_string_view<_CharT> __padding{__padding_chars, __buflen};
 
       auto __pad = [&__padding] (size_t __n, _Out& __o) {