Re: [PATCH 0/2] -Wuninitialized
- From
Ramsay Jones <ramsay@ramsayjones.plus.com>
- Date
- Mar 20, 2018, 23:02 UTC
- Message-ID
- <b939f3e7-9ccf-9a26-9ccf-2b2c13853e42@ramsayjones.plus.com>
- In-Reply-To
- <nycvar.QRO.7.76.6.1803201514490.55@ZVAVAG-6OXH6DA.rhebcr.pbec.zvpebfbsg.pbz>
On 20/03/18 14:46, Johannes Schindelin wrote:
Show 15 quoted lines
> Hi Ramsay, > > On Mon, 19 Mar 2018, Ramsay Jones wrote: > >> 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!
These patches are based on a very old branch (that goes back at least as far as 2010, see [1]). (I have too many in my repo, so it will be good to remove this one)!
Show 5 quoted lines
> 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
Oh, wow! (Hmm, actually that doesn't look too bad :-D )
Show 8 quoted lines
> 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
Thanks for testing the patches.
> So here is my ACK, in case you want it ;-)
Thanks!
ATB, Ramsay Jones
[1] https://public-inbox.org/git/4CFA8D4D.2020500@ramsay1.demon.co.uk/