www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2356] New: array literal as non static initializer generates horribly inefficient code.

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2356

           Summary: array literal as non static initializer generates
                    horribly inefficient code.
           Product: D
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Keywords: wrong-code
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: tomas famolsen.dk


this simple test:

void main()
{
    int[3] x = [1,2,3];
}

should just initialize x with the values 1,2,3

what happens in reality is not as nice as this output of obj2asm shows:

_Dmain:
                push    EBP
                mov     EBP,ESP
                sub     ESP,0Ch
                push    EBX
                lea     EAX,-0Ch[EBP]
                push    EAX
                push    3
                push    3
                push    2
                push    1
                push    3
                mov     ECX,offset FLAT:_D11TypeInfo_Ai6__initZ SYM32
                push    ECX
                call    near ptr _d_arrayliteralT PC32
                add     ESP,014h
                mov     EDX,EAX
                mov     EBX,3
                push    EDX
                push    EBX
                push    4
                call    near ptr _d_arraycopy PC32
                xor     EAX,EAX
                add     ESP,014h
                pop     EBX
                leave
                ret


I'm marking it wrong-code, even though the code does compile and link, it's
just wrong ... I'm using 1.034 but I'd guess it's an older bug, so I'm not
marking a specific version.


-- 
Sep 11 2008
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2356


tomas famolsen.dk changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|unspecified                 |1.034




------- Comment #1 from tomas famolsen.dk  2008-09-15 08:52 -------
I think this issue might have been introduced in DMD 1.034, as I've hit several
issues in LLVMDC, that used to work, due to some initializers suddenly being
ArrayLiterals instead of ArrayInitializers. Marking version 1.034.


-- 
Sep 15 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2356


clugdbug yahoo.com.au changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|wrong-code                  |performance




------- Comment #2 from clugdbug yahoo.com.au  2009-04-08 08:01 -------
This is a performance issue, not wrong-code.


-- 
Apr 08 2009
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2356


bearophile_hugs eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs eml.cc


--- Comment #3 from bearophile_hugs eml.cc 2010-07-19 23:18:32 PDT ---
*** Issue 4488 has been marked as a duplicate of this issue. ***

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