Return a dynamic array: real bug!

Don Clugston dac at nospam.com.au
Wed Jul 4 04:11:20 PDT 2007


Gilles G. wrote:
> However, I really ran into trouble yesterday returning a static array using dmd. Here is how I do it:
>    import std.stdio;
>     int[] testGood()
>     {
>         int a[]; a.length=2;

 >    int[] testBad()
>         int a[2];

These lines have totally different meanings. The first 'a' is allocated on the 
heap, the second one on the stack. It has nothing to do with in/out/body.


More information about the Digitalmars-d-learn mailing list