Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: fix occasional warning
On Mon, 06 Jun 2011 12:32:55 +0100, Vincent Lefevre <vincent@xxxxxxxxxx>
wrote:
On 2011-06-06 10:03:58 +0100, Peter Stephenson wrote:
The code here is actually safe, but some (now old) versions of gcc
produce a warning anyway. Better to rely on more recent versions
optimising out the unused value.
But recent or future GCC versions may warn against values set but
unused.
The code is of this form:
uint16 value = 0; /* this is strictly unnecessary */
uint16 value_set = 0;
if (some_test)
{
value = some_value;
value_set = 1;
}
/* ... */
if (value_set)
{
do_something_with(value):
}
If compilers start warning about unused initialisation to
value in a case like this, I for one will get very cross.
It is having no other effect than making it hard for you
to write safe, portable code.
pws
Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog
Messages sorted by:
Reverse Date,
Date,
Thread,
Author