home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / sys / next / programm / 5855 < prev    next >
Encoding:
Text File  |  1992-08-29  |  1.2 KB  |  57 lines

  1. Path: sparky!uunet!snorkelwacker.mit.edu!ai-lab!next.cambridge.ma.us!simsong
  2. From: simsong (Simson L. Garfinkel)
  3. Newsgroups: comp.sys.next.programmer
  4. Subject: Re: "bind"ing sockets, -ObjC, and memset....A puzzle
  5. Message-ID: <1992Aug28.190230.2670@next.cambridge.ma.us>
  6. Date: 28 Aug 92 19:02:30 GMT
  7. References: <1992Aug26.043241.2355@relief.com>
  8. Sender: simsong@next.cambridge.ma.us
  9. Reply-To: simsong@next.cambridge.ma.us
  10. Organization: Simson Garfinkel and Associates, Inc.
  11. Lines: 44
  12.  
  13. Apparently, when you include the -ObjC flag, all stack variables are  
  14. initialized to 0.
  15.  
  16. Here's a simple test program:
  17.  
  18. int     foo(n)
  19. {
  20.         int     a,b;
  21.         char    f[2342];
  22.         int     c;
  23.  
  24.         printf("a=%d  b=%d  c=%d\n",a,b,c);
  25.         a = n;
  26.         c = n;
  27. }
  28.  
  29. main()
  30. {
  31.         int a,b,c;
  32.  
  33.         foo(0);
  34.         foo(2);
  35. }
  36.  
  37.  
  38.  
  39. And here is the output:
  40.  
  41. altos> cc x.c
  42. altos> a.out
  43. a=84032826  b=212  c=0
  44. a=212  b=57628  c=0
  45. altos> cc -ObjC x.c
  46. altos> a.out
  47. a=0  b=0  c=0
  48. a=0  b=0  c=0
  49. altos> %
  50.  
  51.  
  52. (ps: Other variables in the sin structure are used; it's always a good idea to  
  53. initialize things to 0.)
  54. -- 
  55.  
  56. ................................................................simson
  57.