[Issue 735] New: dmd segfault

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Dec 24 17:54:22 PST 2006


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

           Summary: dmd segfault
           Product: D
           Version: 0.178
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: davidl at 126.com


testmain.d
import modulefault;
interface ITestClass {
 void callable();
}
void main()
{
        auto testLibrary = new testclass;
        auto testCtor =
testLibrary.getCtor!(ITestClass,"test.testmodule.TestClass")();
}


modulefault.d

struct mystruct {
        char[] mystring;
        void opCall(char[] hello)
        {
                mystring = hello;
        }
        public void* address;
}
class testclass{
        template getCtor(TInterface, char[] classname,T...) {
                static ClassInfo typeClass;
                static Object function (T, Object) rawCtor;
                static TInterface internalCtor(T t) {
                        auto a = _d_newclass(typeClass);
                        rawCtor(t, a);
                        return cast(TInterface)a;
                }

                TInterface function(T) getCtor() {
                        typeClass = getClassInfo!(classname)();
                        char[] localchar;
                        foreach(a;T)
                        {
                                localchar~=a.mangleof;
                        }

                        rawCtor = cast(Object function (T, Object)) getSymbol(
                                "_D" ~ mangleSymbolName!(classname) ~
mangleSymbolName!("_ctor") 
                                ~ "F" ~ localchar
                                ~ "ZC" ~ mangleSymbolName!(classname)).address; 

                        return &internalCtor;
               }
        }
        template getClassInfo(char[] classname){
                ClassInfo getClassInfo(){
                        return cast(ClassInfo)getSymbol("__Class_").address;

                }
        }       
        mystruct getSymbol(char[] hello)
        {
                return mystruct(hello);
        }
}


notice: any grammar mistake in getClassInfo would still trigger this segfault
so i guess the problem is in the parser


-- 



More information about the Digitalmars-d-bugs mailing list