Re: [PATCH] removal of "static foo = 0"

Russell King
2000-11-25T21:37:57Z

Andries Brouwer writes:
> What a strange reaction. If I write
>
> static int foo;
>
> this means that foo is a variable, local to the present compilation unit,
> whose initial value is irrelevant because it will be assigned to before use.

Wrong. The initial value is well-defined. Go and read any C standard you
choose. Any C standard you care. You will find out something really
interesting. I can guarantee that you will find out that it will be
initialised to zero. Unconditionally. No question. Absolutely.

> It is a bad programming habit to depend on this zero initialization.

Why? Again, it is WELL defined, and is WELL defined in any C standard.

> Indeed, very often, when you have a program that does something
> you need to change it so that it does that thing a number of times.
> Well, put a for- or while-loop around it. But wait! The second time
> through the loop certain variables need to be reinitialized. Which ones?
> The ones that were initialized explicitly in your first program.
> Make the program into a function in a larger one. Same story.

Your point here is as clear as mud.

> If it is your intention to destabilize then you need not read the following.
> But let us assume that you try to make a perfect system.

There is absolutely NO destabilisation going on here. Get a grip, read the
C standards, read the C startup code. Then come back with something more
relevent.
_____
|_____| ------------------------------------------------- ---+---+-
| | Russell King rmk@arm.linux.org.uk --- ---
| | | | http://www.arm.linux.org.uk/personal/aboutme.html / / |
| +-+-+ --- -+-
/ | THE developer of ARM Linux |+| /|\
/ | | | --- |
+-+-+ ------------------------------------------------- /\\\ |