Re: [PATCH/RFC] reflog: silence -O3 -Wuninitialized warning
- From
Jonathan Nieder <jrnieder@gmail.com>
- Date
- Mar 16, 2011, 09:47 UTC
- Message-ID
- <20110316094639.GA8180@elie>
- In-Reply-To
- <4D807E66.40504@viscovery.net>
Johannes Sixt wrote:
> unsigned long expire = 0;
The main downside is that that prevents valgrind from discovering when the variable really is used uninitialized. But I do agree that
unsigned long expire = expire;
is ugly, which is part of why I did not use the latter workaround in this patch.
Since the makefile already controls what options are passed to msvc, is there some simple way to suppress the warning from "expire = expire"? If not, I would find it tempting to make this and similar examples look like "unsigned long expire;", treat the warning as evidence that either
- the code is too complicated or does not give sufficient hints to the compiler about control flow, or - the compiler has a bug
and use -Wno-uninitialized for -Werror builds.