phobos.lib errors/bug?

Derek Parnell derek at nomail.afraid.org
Mon Jun 26 23:49:36 PDT 2006


On Tue, 27 Jun 2006 01:27:15 +0000 (UTC), MM wrote:
 
> Is this a bug?

Yes. Its a bug in v3.01 of Build (which BTW is not a DigitalMars product).
The current version does not have this problem. Download 3.02 or use "-R:N"
switch when building it.

build -R:N main.d

However, your code will still not run because you are trying to create a
1,000,000 element array on the stack and that will be bigger than the stack
space for your app. Here is alternate code that does the same but uses the
heap rather than the stack ...

==================
private import std.stdio;
private import std.perf;

const int TILEW = 1000;
const int TILEH = 1000;

struct TILE { int x,y; int z[1]; }

void foo(TILE[] arr, int i)
{
    arr[(i%TILEW)*TILEH + (i%TILEH)].z[0]=i;
}

void main()
{
    PerformanceCounter c = new PerformanceCounter();
    int i;
    TILE[] arr2;

    // Allocate contiguous space for all the entries.
    arr2.length = TILEW * TILEH;
    c.start();
    for(i = 0; i < 10000000; i++)
        foo(arr2,i);
    c.stop();
    writefln("foo took: ",c.milliseconds());


}
==================


-- 
Derek
(skype: derek.j.parnell)
Melbourne, Australia
"Down with mediocrity!"
27/06/2006 4:45:23 PM



More information about the Digitalmars-d-bugs mailing list