[Issue 2356] New: array literal as non static initializer generates horribly inefficient code.
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Sep 11 11:46:30 PDT 2008
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 at digitalmars.com
ReportedBy: tomas at 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 at SYM32
push ECX
call near ptr _d_arrayliteralT at PC32
add ESP,014h
mov EDX,EAX
mov EBX,3
push EDX
push EBX
push 4
call near ptr _d_arraycopy at 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.
--
More information about the Digitalmars-d-bugs
mailing list