array construction without heap alloc

0ffh frank at frankhirsch.youknow.what.todo.net
Fri Dec 21 17:09:09 PST 2007


I compiled this using D1 (DMD):

   void bar( int a, int b )
   {
     int[2] arr=[a,b];
     int brr;
     int[] crr;
     crr.length=2;
     func( arr );
     printf("%p %p\n",&arr,arr.ptr);
     printf("%p\n",&brr);
     printf("%p %p\n",&crr,crr.ptr);
   }

It gives me &arr==arr.ptr, which is near &brr and &crr,
while crr.ptr is somewhere completely different.
I suppose that kinda proofs it. =)
Hope it's helpful.

regards, frank


More information about the Digitalmars-d-learn mailing list