Re: [PATCH] Fix -Wmaybe-uninitialized warnings under -O0
- From
Jeff King <peff@peff.net>
- Date
- Apr 1, 2020, 09:52 UTC
- Message-ID
- <20200401095255.GA60227@coredump.intra.peff.net>
- In-Reply-To
- <33984eeaabbfbcfd4b9d3903549d8b7d6c4ced7e.1585726172.git.liu.denton@gmail.com>
On Wed, Apr 01, 2020 at 03:30:16AM -0400, Denton Liu wrote:
Show 9 quoted lines
> 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?
-Peff