<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/124814>124814</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[libc][test] spew of `-Wuninitialized` with gcc-14
</td>
</tr>
<tr>
<th>Labels</th>
<td>
libc
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
michaelrj-google
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
nickdesaulniers
</td>
</tr>
</table>
<pre>
I'm seeing a large spew of:
```
In constructor ‘__llvm_libc_20_0_0_git::testing::FormatSectionMatcher::FormatSectionMatcher(__llvm_libc_20_0_0_git::printf_core::FormatSection)’,
inlined from ‘virtual void LlvmLibcPrintfParserTest_DoublePercentIsAllowedInvalidIndex::Run()’ at /android0/llvm-project/libc/test/src/stdio/printf_core/parser_test.cpp:626:3:
/android0/llvm-project/libc/test/UnitTest/PrintfMatcher.h:25:9: error: ‘expected0.__llvm_libc_20_0_0_git::printf_core::FormatSection::conv_val_ptr’ is used uninitialized [-Werror=uninitialized]
25 | : expected(expectedValue) {}
| ^~~~~~~~~~~~~~~~~~~~~~~
/android0/llvm-project/libc/test/src/stdio/printf_core/parser_test.cpp: In member function ‘virtual void LlvmLibcPrintfParserTest_DoublePercentIsAllowedInvalidIndex::Run()’:
/android0/llvm-project/libc/test/src/stdio/printf_core/parser_test.cpp:621:46: note: ‘expected0.__llvm_libc_20_0_0_git::printf_core::FormatSection::conv_val_ptr’ was declared here
621 | LIBC_NAMESPACE::printf_core::FormatSection expected0;
| ^~~~~~~~~
```
when building the unit tests with gcc-14.
Perhaps `EXPECT_PFORMAT_EQ` is a macro that constructs a `FormatSectionMatcher`, which copy constructs the `FormatSection` `expected` (highlighted in the diagnostic), but the default implicit copy constructor of `FormatSectionMatcher` is copying over every field, where fields such as `FormatSection::conv_val_ptr` and `FormatSection::conv_val_raw` have not been initialized!
I wonder if we should either:
- have the unit tests that default construct `FormatSection`'s initialize `conv_val_ptr` and `conv_val_raw`
- explicitly delete the implicit default constructor for `FormatSection` and update the tests
- other?
Observed while trying to test #124036.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy8VkFv2zYU_jX05SEGRVmyfPBBcWzAQLt6bbbuJlDks8SOJgWSspsd9tsHSm7iJl6XYECVHEyRj-973_fxidx71RjEJcluCWMHJVqO2n25aaxtNBLGSHY34X1orVsaJf6U6HmvjULnJ7WVD8stYfMDeERlGuCguWsQfIcnsHuSloSWJKfnf1puDQhrfHC9CNYBWTNSULIoqkrr46HSqhYVo1X8a1SI8WkZ0AdlmnGwse7AwycUQVnzngfRovvBDPvhzp1TJuwrYR1e2YOwxTd8C8JWhJYAAMpoZVDC3tnDE_6jcqHnGo5WSXinj4d3qha7Yfsddx7dPfpQ3dm-1rhDJ9CErS-1tieUW3PkWsmtkfh1hPGxN4QVl_mBByBsw410VklK2CZWddM5-wVFiENVC8I2kSvCNt7FgQ9SWcI2l2WyTTfgqeLKqeg6kpY5y0lapme1Xp_lN6PC_fhzLPXM-rQlackykpYLkpaAztmo0RNb-LVDEVDS6f9QZ3glrDlWR66rLrgnspSH3qOE3iijguJa_YUSSHZ78_kM5u67KZLdjeqyDMh8BeMzYD8jJewR9O9c90jYAsj8lszPgXH5YyAAydZ_X33eRvDbZIStgQMeanSw781A0s8z6JvN81aLJiQtZ9GnYGzAn2qnE_cgUWjuUEKLDgfNc5acNX-3vV1Vv5Tv15925Wr9mmyPvqIkvb3qoFc9FzaL5H_fak8tGqh7pWXszKHFeBwCRFI9nFRooRHiJplNx9AdupZ3HkhO13_s1qv7arf58PF9eV-tfyU5jWeKw4ELZyG0PDy18fie5PRq-80pYSs4tUq0IGz3cBkVET2Pi4lITh9PXRyyolVNq1XTBpSgzBAoFW-M9UGJaEK2groP4wTuea8DqEOnlVDhWVrrwO5_ADeWGSMiZfaIDvCI7gH2CrUcS0GH49CD70UL3L-s4qWXcgrcyP9a6fgprmz5EaPLoUY0cNmnWDKKtYWTNRIdqD2cEHxrey0BV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