Comment #0 by siegelords_abode — 2013-06-30T16:36:45Z
DMD 2.063.2. Linux 64 and 32 bit. You need two files for this, test.d and testlib.d.
test.d:
~~~
import testlib;
void main()
{
auto arr = new Array;
auto b = new BufferedOutput(arr);
b.flush();
}
~~~
testlib.d:
~~~
interface OutputStream
{
size_t write(size_t len);
}
class BufferedOutput
{
OutputStream sink;
size_t index = 0;
size_t extent = 1;
this (Array stream)
{
sink = stream;
}
void flush()
{
while (extent - index > 0)
{
reader(&sink.write);
}
}
void reader(scope size_t delegate (size_t) dg)
{
index += dg(extent - index);
}
}
class Array : OutputStream
{
override size_t write (size_t len)
{
return len;
}
}
~~~
Compile and link those two files as follows:
dmd testlib.d -shared -O -fPIC -release -m32
dmd test.d -L./testlib.so -m32
If you run ./test, you'll get an infinite loop. If you remove most any flag (including -m32) it'll run correctly. If you paste the contents of testlib.d into test.d, it'll run correctly too. If you use static linking, it'll run correctly.
Comment #1 by code — 2013-08-13T06:55:04Z
*** This issue has been marked as a duplicate of issue 10462 ***