Ryan Joseph via fpc-pascal <fpc-pascal@lists.freepascal.org> schrieb am
Mo., 16. März 2020, 07:33:

> Ok, that makes sense now. Dynamic arrays can't be passed to static arrays.
> I
> remember when I tried to make aligned dynamic arrays I got to look around
> in
> the code and it seems plausible you could just make a memcpy call in the
> RTL
> for dynamic arrays being passed to static arrays. Seems deceptively easy.
> :)
>

You forget managed types. You can't do a simple Move for them.


> Shouldn't it be a constant array though? I'm not sure how the compiler
> works
> but from the programers perspective I thought I was getting something
> without runtime allocation because the array contained only constant
> values.
>

It's only a constant array if it's declared in the const section. Inside
normal code it can also contain variables, function calls, just any
expression really.

Though it would be a potential optimization if all entries are constant to
treat it as a constant array. Again that is something that *could* be done,
but is not right now.

Regards,
Sven

>
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to