[Issue 5788] New: Return [] array

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Mar 27 14:45:38 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=5788

           Summary: Return [] array
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at eml.cc 2011-03-27 14:42:14 PDT ---
A little D2 program:


int[] foo() {
    return [];
}
int[] bar() {
    return null;
}
void main() {}


The asm of the two functions, compiling it with DMD 2.052:
dmd -O -release -inline test2.d


_D5test23fooFZAi    comdat
L0:     push    EAX
        mov EAX,offset FLAT:_D11TypeInfo_Ai6__initZ
        push    0
        push    EAX
        call    near ptr __d_arrayliteralT
        mov EDX,EAX
        add ESP,8
        pop ECX
        xor EAX,EAX
        ret

_D5test23barFZAi    comdat
        xor EAX,EAX
        xor EDX,EDX
        ret


I am not sure, but I think it's better to compile foo() to the same assembly as
bar().

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list