Stack-allocated arrays

Derek Parnell derek at psych.ward
Tue Nov 11 12:47:01 PST 2008


On Tue, 11 Nov 2008 17:39:07 +0000 (UTC), dsimcha wrote:

> If length is larger than some arbitrary but reasonable value, this is heap
> allocated.  If length is small, it is stack allocated.  Either way, allowing
> the array to escape the current scope is undefined behavior and the compiler
> would detect at least the simple cases of this.  Ideally, since this would
> only be used for temp variables in performance-critical code, the contents of
> the array would also not be initialized.

Would there be a problem if multiple stack-arrays were asked for. It might
be that one or two such arrays are not going to upset the stack size but
allocating 100 of them on the same stack might be a problem. Can the
compiler help here?

-- 
Derek Parnell
Melbourne, Australia
skype: derek.j.parnell



More information about the Digitalmars-d mailing list