home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / os / linux / 22123 < prev    next >
Encoding:
Text File  |  1992-12-30  |  1.9 KB  |  47 lines

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