Date: Tue, 13 Aug 1996 13:51:35 +0200 (IST) From: Eli Zaretskii To: Francois Charton Cc: djgpp AT delorie DOT com Subject: Re: Freeing and not freeing Windoze memory In-Reply-To: <32105403.267E@pobox.oleane.com> Message-Id: Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Tue, 13 Aug 1996, Francois Charton wrote: > BTW, do you think it would be possible for a compiler to optimise the use > of memory (i.e. allocate in the stack whenever it is safe and possible, > and in the heap in other time). Comments anyone ? For this to be done, the compiler should be smart enough to know whether the pointer returned by the memory-allocation function should remain valid outside the current block. If it should, `alloca' cannot be used, since its storage is automagically freed when the stack is popped. As C has the usual pointer-aliasing problems, I suspect this is beyond the current level of source code analysis done by any reasonable compiler (many of them don even have an `alloca', or have one with a buggy implementation). Imagine how many complains about gcc slow compiles will we see if a compiler would to make such an analysis! Thanks, but no, thanks!