[Issue 1434] DMD COM design flaw
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Mon Aug 20 02:41:37 PDT 2007
    
    
  
http://d.puremagic.com/issues/show_bug.cgi?id=1434
------- Comment #3 from davidl at 126.com  2007-08-20 04:41 -------
the following is a bit more clear:
import std.stdio;
interface IUnknown
{
        void hello();
}
class k:IUnknown 
{
        invariant
        {
                writefln("hello");
        }
        this()
        {
                writefln("this class!");
        }
        void hello()
        {
                writefln("this class!");
        }
}
void main()
{
// following only illustrate the C side instantiating a COM object
        k v=new k;
        Object o=v;
        ClassInfo c = o.classinfo;
        int *m=cast(int*)(&c.classInvariant); 
        *m= 1;
// now we can a COM object , we call through our interface
        IUnknown t=v;
        t.hello();   // invariants calling?? C side code could ruin the field
like the code above
}
-- 
    
    
More information about the Digitalmars-d-bugs
mailing list