[Issue 915] dmd generate bad form return(retn 4) for invariant func

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Feb 1 06:54:10 PST 2007


http://d.puremagic.com/issues/show_bug.cgi?id=915





------- Comment #1 from davidl at 126.com  2007-02-01 08:54 -------
a simpler case, but we don't see any exception get caught. 
de-comment the ret , we can see the code work correctly.
though i find in some situation , the case actually in a ctor
before calling my invariant , dmd first push some thing on the stack
and the windows directive makes it seems right( that's quite weird)
 and the next time calling my invariant in my case, it's 
from _d_invariant, the situation is different , _d_invariant need 
the invariant func retn directly instead of "retn 4".

import std.stdio;
package class invarianttest
{
        extern(D):
        this(Object test,int i)
        {
                myobject = test;
                writefln(`class tester`,i);
        }
        extern(Windows):
        invariant
        {
                writefln(`hello invariant`);
                asm
                {
//                      ret;
                }
        }

extern (Windows):
        void func()
        {
                printf(`func`);
        }
        void method()
        {
                writefln(`method`);
        }
        extern(D):
        private:
        Object myobject;
}
void main()
{
        Object t=new Object;
        auto inst= new invarianttest(t,1);
        inst.func();
        inst.method();
}


-- 



More information about the Digitalmars-d-bugs mailing list