On Sat, 22 Nov 2014 19:07:14 +0400
drug via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com> wrote:

> Sorry for inconvenience.
> http://dpaste.dzfl.pl/64ab69ae80d2
> this causes stackoverflow because static array is big enough. I'd like 
> to pass it not by value to avoid stack overflowing. Even if I use ref 
> dmd pass it by value.
ah, that's why we need to look at the code! ;-)

what you have here is multidimensional static array, so 'ref' is not
working as you expected. let's just say that you can't do this with
'ref' and static arrays, 'cause compiler will copy some of the data
anyway.

multidimensional static array is just a continuous region of memory, not
a pointer to regions, as dynamic arrays. so compiler can't make
reference to `[A][B]` (for now, at least). either use dynamic arrays as
Ali suggested, or do all the pointer math manually (i.e. pass &arr[0]0]
and all dimensions).

it's a bad practice to have such big arrays on the stack anyway.

Attachment: signature.asc
Description: PGP signature

Reply via email to