Issue 124814
Summary [libc][test] spew of `-Wuninitialized` with gcc-14
Labels libc
Assignees michaelrj-google
Reporter nickdesaulniers
    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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to