www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10515] New: -shared -O -release -fPIC -m32 generates a broken library

reply d-bugmail puremagic.com writes:
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 puremagic.com
        ReportedBy: siegelords_abode yahoo.com



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: -------
Jun 30 2013
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10515


Martin Nowak <code dawg.eu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |code dawg.eu
         Resolution|                            |DUPLICATE



*** This issue has been marked as a duplicate of issue 10462 ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 13 2013