Returning fixed size arrays

John Colvin via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jun 25 16:51:50 PDT 2014


On Wednesday, 25 June 2014 at 20:59:29 UTC, bearophile wrote:
>> Is it possible and a good idea to change the D ABI to make 
>> code like this avoid an array copy in 100% of the cases 
>> (without inlining)?
>
> I meant, letting the compiler rewrite that code like this:
>
>
> void foo(ref ubyte[1000] __data) nothrow @safe {
>     __data[] = 0;
>     // some code here.
> }
> void main() nothrow {
>     ubyte[1000] __data = void;
>     foo(__data);
>     immutable data = cast(immutable ubyte[1000])__data;
> }
>
>
> Bye,
> bearophile

perhaps i'm misunderstanding things, but isn't this exactly what 
the System V ABI specifies anyway? Large aggregate returns are 
allocated on the calling stack, passed by hidden pointer.


More information about the Digitalmars-d-learn mailing list