[Issue 10515] New: -shared -O -release -fPIC -m32 generates a broken library
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Jun 30 16:36:46 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10515
Summary: -shared -O -release -fPIC -m32 generates a broken
library
Product: D
Version: D2
Platform: x86
OS/Version: All
Status: NEW
Keywords: wrong-code
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: siegelords_abode at yahoo.com
--- Comment #0 from siegelords_abode at yahoo.com 2013-06-30 16:36:45 PDT ---
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.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list