<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/3.12.3">
</HEAD>
<BODY>
On Thu, 2007-05-31 at 05:52 -0500, Mike McCarty wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
<FONT COLOR="#000000">Andy Green wrote:</FONT>
<FONT COLOR="#000000">> Mike McCarty wrote:</FONT>

<FONT COLOR="#000000">[snip]</FONT>

<FONT COLOR="#000000">>>C doesn't initialize what? It initializes all used variables.</FONT>
<FONT COLOR="#000000">> </FONT>
<FONT COLOR="#000000">> </FONT>
<FONT COLOR="#000000">> Not if they're on the stack.  You should get a compiler warning</FONT>
<FONT COLOR="#000000">> nowadays... but don't count on it!</FONT>

<FONT COLOR="#000000">Erm, C knows nothing about a "stack". However, it is true</FONT>
<FONT COLOR="#000000">that automatic variable are not necessarily initialized.</FONT>
<FONT COLOR="#000000">I should have stated that all statically allocated variables</FONT>
<FONT COLOR="#000000">are initialized. Thanks for the correction.</FONT>

<FONT COLOR="#000000">Mike</FONT>
<FONT COLOR="#000000">-- </FONT>
</PRE>
</BLOCKQUOTE>
That must be something recent.  Also some people believed that it did in the past, but it did not.  The variables are just assigned space.  The contents of the space was whatever was left from the prior use.  Since many developers reboot before starting development, the space is often preset to 0, due to memory checks or perhaps a behavior of some dynamic ram operation, they believed the variables were initiaized, but they were not.  This was as of 2000 on a SUN Solaris 8 system using K&R.  I know this for a fact.  As to how different compilers deal with it, the static variable space is between the initial entry jump and the beginning of code in most designs, and that space may be initialized by the compiler at compile time, such that uninitialized variables are preset to 0.  But the original K&R spec did not include initializing variables except explicitly.<BR>
<BR>
    This part I am sure of, because I have had to fix many, many peoples code due to this belief.  The ANSI comittee may have changed the standard, but I would bet that a lot of older compilers still generate code with no initialization.<BR>
<BR>
Regards,<BR>
Les H
</BODY>
</HTML>