View mode: basic / threaded / horizontal-split · Log in · Help
October 06, 2009
[Issue 3370] New: Compile-time global dynamic immutable arrays should NOT be constant-folded.
http://d.puremagic.com/issues/show_bug.cgi?id=3370

          Summary: Compile-time global dynamic immutable arrays should
                   NOT be constant-folded.
          Product: D
          Version: 2.033
         Platform: Other
       OS/Version: Windows
           Status: NEW
         Keywords: performance
         Severity: critical
         Priority: P2
        Component: DMD
       AssignedTo: nobody@puremagic.com
       ReportedBy: dsimcha@yahoo.com


--- Comment #0 from David Simcha <dsimcha@yahoo.com> 2009-10-06 15:04:05 PDT ---
The following program runs out of memory b/c foo is apparently allocated and
created every time through the loop:

import std.math, core.memory, std.stdio;

immutable real[] foo = [0,1,2,3,4];

void main() {
   GC.disable;

   foreach(i; 0..1_000_000_000) {
       auto bar = poly(i, foo);
   }
}

Changing the immutable to an enum results in the program still running out of
memory.  

Removing all references to immutability fixes the problem.  

Changing the array to a static array fixes the problem.

Initializing the array inside main() fixes the problem.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 25, 2010
[Issue 3370] Compile-time global dynamic immutable arrays should NOT be constant-folded.
http://d.puremagic.com/issues/show_bug.cgi?id=3370


David Simcha <dsimcha@yahoo.com> changed:

          What    |Removed                     |Added
----------------------------------------------------------------------------
            Status|NEW                         |RESOLVED
        Resolution|                            |DUPLICATE


--- Comment #1 from David Simcha <dsimcha@yahoo.com> 2010-07-25 10:09:58 PDT ---
Marking as dup of bug 4298.  Although this report was filed first, 4298 is were
all the discussion is, and it's a somewhat better bug report.

*** 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: -------
Top | Discussion index | About this forum | D home