www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 735] New: dmd segfault

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


-- 
Dec 24 2006
next sibling parent Thomas Kuehne <thomas-dloop kuehne.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

d-bugmail puremagic.com schrieb am 2006-12-25:
 http://d.puremagic.com/issues/show_bug.cgi?id=735
<snip>
 notice: any grammar mistake in getClassInfo would still trigger this segfault
 so i guess the problem is in the parser
David please follow the common bug reporting guidelines outlined at http://www.digitalmars.com/bugs.html and http://www.prowiki.org/wiki4d/wiki.cgi?D__Tutorial/BugReports reducing your code results in 4 lines that reliable reproduce the bug: Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFFkAASLK5blCcjpWoRArS5AJwNeMI94ctI+Q0e+/M0v0p3ys3GjgCfSDEj QHvJb7IGw1n7rs4BlfqPF74= =/l+x -----END PGP SIGNATURE-----
Dec 25 2006
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=735


davidl 126.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |critical
            Summary|dmd segfault                |forward reference to type
                   |                            |Object??
            Version|0.178                       |1.005





err, dmd not segfault any more, but 
if i add the following to modulefault.d to make it compile :
extern(D) Object _d_newclass(ClassInfo a);

dmd throws me:

modulefault.d(16): Error: forward reference to type Object
modulefault.d(16): Error: cannot implicitly convert expression (a) of type
objec
t.Object to Object


-- 
Feb 12 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=735






the following represents the bug :

simplified case: buginawhole.d 

extern(D) Object _d_newclass(ClassInfo a);
class testclass{
        template getCtor(TInterface, char[] classname,T...) {
                static ClassInfo typeClass;
                static Object function (T, Object) rawCtor;
                static TInterface internalCtor(T t) {
                        Object a = _d_newclass(typeClass);
                        rawCtor(t, a);
                        return cast(TInterface)a;
                }

                TInterface function(T) getCtor() {
                        return &internalCtor;
               }
        }

}

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

modulefault.d(8): Error: forward reference to type Object
modulefault.d(8): Error: cannot implicitly convert expression (a) of type
object
.Object to Object


-- 
Feb 12 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=735


braddr puremagic.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|critical                    |normal
            Version|1.005                       |0.178




-- 
Feb 15 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=735






I can't reproduce any of the forward reference errors with DMD 1.018. Has this
been fixed already?


-- 
Jul 02 2007
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=735


onlystupidspamhere yahoo.se changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WORKSFORME





Cannot reproduce any forward reference errors so works for me.


-- 
Jul 05 2007