home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.os.linux
- Path: sparky!uunet!think.com!spool.mu.edu!umn.edu!csus.edu!netcom.com!qualtrak
- From: qualtrak@netcom.com (Qual Trak)
- Subject: Re: IMPORTANT [BUG in 0.99] Re: [ANNOUNCE]: linux version 0.99
- Message-ID: <1992Dec30.050610.1728@netcom.com>
- Organization: QualTrak Corporation
- References: <1hpsasINN6e@meaddata.meaddata.com> <20502@ksr.com> <mcampbel.725666039@eola.cs.ucf.edu>
- Date: Wed, 30 Dec 1992 05:06:10 GMT
- Lines: 36
-
- In article <mcampbel.725666039@eola.cs.ucf.edu> mcampbel@cs.ucf.edu (Mike Campbell ) writes:
- >zdenek@ksr.com (Zdenek Radouch) writes:
- >
- >>Stephen Williams writes:
- >
- >>>Statics are either explicitly initialized or they are not.
- >>>If they are not, their contents are UNDEFINED until set.
- >>>This is per ANSI C.
- >>>There is NO requirement of the compiler or system to zero
- >>>un-initialized statics (or auto's).
- >
- >
- >>I'll quote for you:
- >
- >>"A static object not explicitly initialized is initialized as if it
- >>(or its members) were assigned the constant 0. The initial value of
- >>an automatic object not explicitly initialized is undefined."
- >
- >
- >You are correct - what would be the advantage of a static in a function?
- >
- >If you NEEDED to initialize it, you would lose the value of the variable
- >every time the function was called, nullifying the advantage statics have
- >in functions, (namely holding a value out of visibility).
-
- You're correct up until the last two paragraphs - Although I can't
- quote chapter and verse, maybe someone else will - a static variable
- with an initializer is initialized exactly one time, which can be
- considered to happen the first time the variable comes into scope.
-
- I looked in k&r 2d ed and couldn't find reference to the above, but I've
- seen it somewhere.
- ----- -----
- John Birchfield - QualTrak Corp (408) 730-2674 Home (408) 736-3852
- jb@QualTrak.COM
- ----- -----
-