Subject: Re: Warnings in nfsv3 code--buggy gcc?
To: Michael L. VanLoon -- HeadCandy.com <michaelv@HeadCandy.com>
From: None <kpneal@eos.ncsu.edu>
List: current-users
Date: 03/30/1996 23:28:19
> 
> 
> >> From: jconklin@netcom.com (J.T. Conklin)
> >> Date: Fri, 29 Mar 1996 07:05:40 -0800 (PST)
> >> -Wuninitialized is a good warning, but since it's not 100%, I don't
> >> recommend combining it with -Werror.  Some people get around this by
> >> always initializing the variable to some dummy value.  I think this
> >> is terrible practice, as it defeats the ability of run-time tools 
> >> that track variable usage to detect uninitialized variable usage.
> 
> >Well, isn't the point to avoid uninitialized variables?
> >If you initialize it, haven't you solved the problem?
> 
> Actually, there's a school of coding practice that says to initialize
> all variables before-hand to avoid compiler-specific bugs (it works on
> one compiler, because it zero-initializes a variable used before
> assigned, then breaks on a different build that doesn't
> zero-initialize; or it works on a certain build where a predictable
> pattern in memory makes things work, then changes in a different build
> because memory is laid out differently), as well as avoiding a bug
> where some new code is inserted into an existing routine, using an
> existing variable before the existing initializer code is reached.
> I'm sure there are many differing opinions on what is "right",
> however...
> 

Me personally, I initialize a variable to zero only if I am going to
do something later like:

var++;

Or something that depends on it starting at zero. Otherwise, why
bother?

It also helps to keep functions reasonably short, to make it easier
to keep track of what needs to be initialized at start.

XCOMM --------------------------------------------------------
XCOMM Kevin P. Neal, Sophomore CSC/CPE     kpneal@eos.ncsu.edu 
XCOMM North Carolina State University      kevinneal@bix.com
XCOMM --------------------------------------------------------