array initializers

David Nadlinger via Digitalmars-d digitalmars-d at puremagic.com
Fri Jul 11 12:01:03 PDT 2014


On Friday, 11 July 2014 at 18:36:14 UTC, Trass3r wrote:
>> By the way, LDC already does this today (even without 
>> optimizations turned on).
>
> My ldc doesn't.

What LDC version are you on?

With Git master, this
---
auto foo() {
    immutable int[] arr = [0, 1, 0, 3];
    return arr;
}
---
produces (with optimizations on, but just for brevity)
---
define { i64, i32* } @_D4test3fooFZyAi() #0 {
   ret { i64, i32* } { i64 4, i32* getelementptr inbounds ([4 x 
i32]* @.immutablearray, i32 0, i32 0) }
}
---

Cheers,
David


More information about the Digitalmars-d mailing list