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

From: Michael Meissner (meissner@spectacle-pond.org)
Date: Sun Nov 26 2000 - 23:00:10 EST


On Sat, Nov 25, 2000 at 11:55:11PM +0000, Tim Waugh wrote:
> On Sat, Nov 25, 2000 at 10:53:00PM +0000, James A Sutherland wrote:
>
> > Which is silly. The variable is explicitly defined to be zero
> > anyway, whether you put this in your code or not.
>
> Why doesn't the compiler just leave out explicit zeros from the
> 'initial data' segment then? Seems like it ought to be tought to..

Because sometimes it matters. For example, in kernel mode (and certainly for
embedded programs that I'm more familiar with), the kernel does go through and
zero out the so called BSS segment, so that normally uninitialized static
variables will follow the rules as laid out under the C standards (both C89 and
C99). I can imagine however, that the code that is executed before the BSS
area is zeroed out needs to be extra careful in terms of statics that it
references, and those must be hand initialized.

-- 
Michael Meissner, Red Hat, Inc.
PMB 198, 174 Littleton Road #3, Westford, Massachusetts 01886, USA
Work:	  meissner@redhat.com		phone: +1 978-486-9304
Non-work: meissner@spectacle-pond.org	fax:   +1 978-692-4482
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu Nov 30 2000 - 21:00:16 EST