I don't know if that bug fix (in dmd 2.060alpha) has fixed your problem too.

I have compiled this code from your issue 7271 with the latest beta:


struct MemoryBlockInfo {
    size_t size;
    long[10] backtrace;
    int backtraceSize;

    this(size_t size) {
        this.size = size;
    }
}
void main() {
    MemoryBlockInfo info;
    info = MemoryBlockInfo.init; //array allocation here
}


Compiling it with no optimization it gives:


_D4temp15MemoryBlockInfo6__ctorMFkZS4temp15MemoryBlockInfo
        enter   4,0
        mov ECX,8[EBP]
        mov [EAX],ECX
        leave
        ret 4

__Dmain comdat
        enter   060h,0
        push    ESI
        push    EDI
        mov ECX,018h
        xor EAX,EAX
        lea EDI,-060h[EBP]
        rep
        stosd
        mov ESI,offset FLAT:_D4temp15MemoryBlockInfo6__initZ
        lea EDI,-060h[EBP]
        mov CL,018h
        rep
        movsd
        pop EDI
        pop ESI
        leave
        ret


With -O -release -inline it becomes:


_D4temp15MemoryBlockInfo6__ctorMFkZS4temp15MemoryBlockInfo  comdat
        push    EAX
        mov ECX,8[ESP]
        mov [EAX],ECX
        pop ECX
        ret 4

__Dmain comdat
        sub ESP,064h
        mov ECX,018h
        xor EAX,EAX
        push    EDI
        lea EDI,4[ESP]
        rep
        stosd
        pop EDI
        add ESP,064h
        ret


In both cases I don't see a memory allocation.

Bye,
bearophile

Reply via email to