From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16137 invoked by alias); 6 Jun 2011 11:47:08 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 29464 Received: (qmail 1710 invoked from network); 6 Jun 2011 11:47:05 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at csr.com does not designate permitted sender hosts) Content-Type: text/plain; charset="iso-8859-15"; format=flowed; delsp=yes To: Subject: Re: PATCH: fix occasional warning References: <20110606113255.GA8105@prunille.vinc17.org> Date: Mon, 6 Jun 2011 12:46:53 +0100 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Peter Stephenson Organization: Cambridge Silicon Radio Message-ID: In-Reply-To: <20110606113255.GA8105@prunille.vinc17.org> User-Agent: Opera Mail/11.11 (Win32) X-Originating-IP: [10.103.10.173] X-Scanned-By: MailControl A-10-80-00 (www.mailcontrol.com) on 10.71.0.135 On Mon, 06 Jun 2011 12:32:55 +0100, Vincent Lefevre 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