Subject: Re: Warnings in nfsv3 code--buggy gcc?
To: Michael L. VanLoon -- <>
From: None <>
List: current-users
Date: 03/30/1996 23:28:19
> >> From: (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:


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

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 
XCOMM North Carolina State University
XCOMM --------------------------------------------------------