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

Re: [PATCH 0/2] -Wuninitialized

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Mar 20, 2018, 14:46 UTC
Message-ID
<nycvar.QRO.7.76.6.1803201514490.55@ZVAVAG-6OXH6DA.rhebcr.pbec.zvpebfbsg.pbz>
In-Reply-To
<8f6d8e2e-aba4-128c-f17c-6c1b9c12436c@ramsayjones.plus.com>
Hi Ramsay,
On Mon, 19 Mar 2018, Ramsay Jones wrote:
Show 9 quoted lines
> This series removes all 'self-initialised' variables (ie. <type> var =
> var;).  This construct has been used to silence gcc
> '-W[maybe-]uninitialized' warnings in the past [1]. Unfortunately, this
> construct causes warnings to be issued by MSVC [2], along with clang
> static analysis complaining about an 'Assigned value is garbage or
> undefined'. The number of these constructs has dropped over the years
> (eg. see [3] and [4]), so there are currently only 6 remaining in the
> current codebase. As demonstrated below, 5 of these no longer cause gcc
> to issue warnings.
Thank you so much for working on this!

In Git for Windows, to work around the MSVC issues you mention, I have this ugly work-around (essentially, it has a FAKE_INIT() macro that either performs that GCC workaround or initializes the variable to NULL/0):

	https://github.com/git-for-windows/git/commit/474155f32a

FWIW I just tested your patches with Visual Studio 2017 and there are no C4700 warnings (the equivalent of GCC's "may be uninitialized" warning) [*1*].

You can find the patches (your patches rebased onto Git for Windows' master, plus a patch adding the project files for Visual Studio) here:

https://github.com/git-for-windows/git/compare/master...dscho:msvc-uninitialized-warning-test
So here is my ACK, in case you want it ;-)

Ciao, Dscho

Footnote *1*: there actually was one, but in a Windows-only patch. That's what that last (fixup!) patch on my branch is all about.

Previous: Ramsay JonesNext: Ramsay Jones
Message 4 of 5 in “-Wuninitialized”
  1. 0/2 -WuninitializedRamsay Jones, Mar 19, 2018
  2. Jeff KingMar 20, 2018
  3. Ramsay JonesMar 20, 2018
  4. Johannes SchindelinMar 20, 2018
  5. Ramsay JonesMar 20, 2018

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.