home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.next.programmer
- Path: sparky!uunet!nevada.edu!oliverm
- From: oliverm@nevada.edu (Moises Oliveira )
- Subject: Re: "bind"ing sockets, -ObjC, and memset....A puzzle
- Message-ID: <1992Aug31.192253.16733@nevada.edu>
- Summary: Programming through guesswork
- Sender: news@nevada.edu (USENET News System)
- Nntp-Posting-Host: helios.nevada.edu
- Organization: Organization? Ha, don't make me laugh
- References: <1992Aug26.043241.2355@relief.com> <1992Aug28.190230.2670@next.cambridge.ma.us> <17tieoINNsr5@news.aero.org>
- Date: Mon, 31 Aug 1992 19:22:53 GMT
- Lines: 53
-
- In article <17tieoINNsr5@news.aero.org> strauss@Aero.org (Daryll Strauss) writes:
- >In article <1992Aug28.190230.2670@next.cambridge.ma.us>, simsong (Simson L. Garfinkel) writes:
- >|> Apparently, when you include the -ObjC flag, all stack variables are
- >|> initialized to 0.
- >|>
- >
- >It would be a really bad idea to rely on that "feature." You must clear
- >the sockaddr structure to use it. The C spec says that stack variables
- >have unknown values. I've need heard anything different in for ObjC. So
- >relying on the compiler to initialize variables for you is a disaster
- >waiting to happen.
-
- It's especially a bad idea seeing as how it's plain out
- untrue! The ObjC flag to the linker DOES NOT clear stack
- variables to 0. When you pass ObjC to the linker, it pulls
- in a bunch of support for ObjC. Because of this, in an
- itsy-bitsy tiny example program like the one posted, a
- large portion of the stack will end up filled with 0
- values.
-
-
- But this will only remain true for the first function
- call. To see what I mean, change the program a bit:
-
- int foo(n)
- {
- int a,b;
- int c;
-
- printf("a=%d b=%d c=%d\n",a,b,c);
- a = n;
- c = n;
- }
-
- main()
- {
- int a,b,c;
-
- foo(17);
- foo(13);
- foo(11);
- foo(7);
- foo(5);
- foo(3);
- foo(2);
- foo(1);
- }
-
- The sample program and output that Simson Garfinkel
- posted works by mere coincidence.
-
-
-
-