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

Michael Meissner
2000-11-27T04:29:42Z

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