git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Fix -Wmaybe-uninitialized warnings under -O0

From
Denton Liu <liu.denton@gmail.com>
Date
Apr 1, 2020, 14:06 UTC
Message-ID
<20200401140643.GA880372@generichostname>
In-Reply-To
<20200401095255.GA60227@coredump.intra.peff.net>
Hi Peff,
On Wed, Apr 01, 2020 at 05:52:55AM -0400, Jeff King wrote:
Show 23 quoted lines
> On Wed, Apr 01, 2020 at 03:30:16AM -0400, Denton Liu wrote:
> 
> > When compiling Git under -O0, gcc (Arch Linux 9.3.0-1) 9.3.0 produces
> > many -Wmaybe-uninitialized warnings. These are false positives since
> > when Git is compiled under -O2, gcc is smart enough to see that the
> > code paths that use these variables all initialise them beforehand.
> > Nonetheless, these warnings block the compilation process when
> > DEVELOPER=1 is enabled (which enables -Werror).
> > 
> > Fix these warnings by initializing these variables with dummy values (0,
> > -1 or NULL as appropriate).
> 
> Hmph. I almost always compile with -O0 and have been using gcc 9.3.0
> since it was packaged for Debian a few weeks ago, but I don't see any of
> these warnings.
> 
> The current version in Debian unstable is 9.3.0-8, which picks up some
> extra patches from the upstream gcc-9 branch. But even if I download a
> snapshot of the original 9.3.0 release, it builds fine.
> 
> So why does your version behave differently? And if this is a temporary
> state for a buggy version of gcc (that may be fixed in the next point
> release), is it worth changing our source code to appease it?

A correction to the earlier message... It seems like I wasn't reporting the correct settings. I was actually compiling with -Og, not -O0 (whoops!).

I tested it with gcc-8 and it seems like it also reports the same problem. Also, -O1 reports warnings as well.

I guess the question is do we only support -O0 and -O2 or should we support the levels in between as well?

Sorry for the confusion,
Denton
> 
> -Peff
Previous: Jeff KingNext: Jeff King
Message 3 of 31 in “Fix -Wmaybe-uninitialized warnings under -O0”
  1. Fix -Wmaybe-uninitialized warnings under -O0Denton Liu, Apr 1, 2020
  2. Jeff KingApr 1, 2020
  3. Denton LiuApr 1, 2020
  4. Jeff KingApr 3, 2020
  5. Jeff KingApr 3, 2020
  6. Denton LiuApr 4, 2020
  7. Jeff KingApr 4, 2020
  8. trace2: refactor to avoid gcc warning under -O3Ævar Arnfjörð Bjarmason, May 5, 2021
  9. Junio C HamanoMay 5, 2021
  10. Jeff KingMay 5, 2021
  11. Johannes SchindelinMay 5, 2021
  12. Junio C HamanoMay 6, 2021
  13. Johannes SchindelinMay 6, 2021
  14. Junio C HamanoMay 6, 2021
  15. Johannes SchindelinMay 11, 2021
  16. Jeff KingMay 11, 2021
  17. Junio C HamanoMay 11, 2021
  18. Jeff KingMay 11, 2021
  19. Junio C HamanoMay 11, 2021
  20. Junio C HamanoMay 11, 2021
  21. trace2: refactor to avoid gcc warning under -O3Ævar Arnfjörð Bjarmason, May 11, 2021
  22. Jeff HostetlerMay 11, 2021
  23. Jeff KingMay 11, 2021
  24. Jeff KingMay 11, 2021
  25. Junio C HamanoMay 11, 2021
  26. Junio C HamanoMay 20, 2021
  27. trace2: refactor to avoid gcc warning under -O3Ævar Arnfjörð Bjarmason, May 20, 2021
  28. Jeff KingMay 20, 2021
  29. Junio C HamanoMay 20, 2021
  30. Jeff KingMay 21, 2021
  31. Denton LiuApr 1, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.