Mail Archives: djgpp/1996/08/13/06:57:16
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!
- Raw text -