From mboxrd@z Thu Jan 1 00:00:00 1970 From: erik quanstrom Date: Sat, 21 May 2016 16:31:43 -0700 To: 9fans@9fans.net Message-ID: <815555697a1341aa642fbc55e2af3579@lilly.quanstro.net> In-Reply-To: <43e28e45269a7c2538dce942df75faea@9netics.com> References: <43e28e45269a7c2538dce942df75faea@9netics.com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: Re: [9fans] bug in authdial() Topicbox-Message-UUID: 9344f55a-ead9-11e9-9d60-3106f5b1d025 On Sat May 21 16:05:58 PDT 2016, 9nut@9netics.com wrote: > >> >> Waitmsg *exitsts = nil; > > i see; it's set but not used before it is assigned to again. > > i would expect the compiler to get the hint that it's initialization > -- especially given that the value is 0 and the assignment is right > with the declaration. like i mentioned, gcc ignores variables that are set and not used, for the most part. i think behavior is odd. there's nothing special about assigning a simple type in a declaration. for example char *s = nil; and char *s; s = nil; are equivalent. gcc ignores both cases if they are not actually used. one could add an automatic implicit USED in kenc by modifying the doinit() in dcl.c, but i think that would be a mistake. i find extra assignments make it harder to read the code, as one has to consider the assignment might be used when evaluating how a variable is used. there are some exceptions to the general rule, for non simple types, where the assignment may change the size. and i'm gnoring some dark corners of c99 like const int, which are not implemented in plan 9. - erik