digitalmars.D.bugs - [Issue 4631] New: const array literal rebuilt on every usage
- d-bugmail puremagic.com (68/68) Aug 12 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4631
- d-bugmail puremagic.com (12/12) Sep 08 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4631
http://d.puremagic.com/issues/show_bug.cgi?id=4631
Summary: const array literal rebuilt on every usage
Product: D
Version: D2
Platform: Other
OS/Version: Windows
Status: NEW
Keywords: performance, wrong-code
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody puremagic.com
ReportedBy: r.sagitario gmx.de
PDT ---
This assertion in this code fails:
module test;
const int[] arr = [ 1, 2, 3 ];
void main()
{
assert(arr.ptr == arr.ptr);
}
Here's the assembly for main:
__Dmain comdat
assume CS:__Dmain
L0: push EBX
push ESI
push 3
push 2
push 1
push 3
mov EAX,offset FLAT:_D12TypeInfo_xAi6__initZ
push EAX
call near ptr __d_arrayliteralT
add ESP,014h
mov ECX,EAX
mov EBX,3
push ECX
push 3
push 2
push 1
push 3
mov EDX,offset FLAT:_D12TypeInfo_xAi6__initZ
push EDX
call near ptr __d_arrayliteralT
add ESP,014h
mov ECX,EAX
mov EAX,3
mov ESI,ECX
pop ECX
cmp ECX,ESI
je L4E
mov EAX,7
call near ptr _D4test8__assertFiZv
L4E: xor EAX,EAX
pop ESI
pop EBX
ret
__Dmain ends
The array literal is constructed on every use, even though the constant array
is written to the _DATA segment of the object file. I tried increasing the
array size if there is some threshold, but with about 50 elements it's still
the same.
using "const(int)[] arr = [ 1, 2, 3 ];" works as expected.
This looks similar to bug 2237, but the code here works ok for D1 while bug
2237 is D1 only.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 12 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4631
David Simcha <dsimcha yahoo.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |dsimcha yahoo.com
Resolution| |DUPLICATE
*** This issue has been marked as a duplicate of issue 4298 ***
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 08 2010








d-bugmail puremagic.com