www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11190] New: DMD segfaults in template resolution with "alias this"

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11190

           Summary: DMD segfaults in template resolution with "alias this"
           Product: D
           Version: D2
          Platform: x86
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: blm768 gmail.com



The following code causes a segfault:

struct SomeStruct(T) {
    T _value;

    //If removed, there is no segfault.
    alias _value this;
}

//If removed or replaced with an actual
//function template, there is no segfault.
template doSomething(T: ulong) {}

void doSomething(T: SomeStruct!T)() {
    assert(false);
}

pragma(msg, doSomething!(SomeStruct!ulong)());

According to GDB:

Program received signal SIGSEGV, Segmentation fault.
0x0000000000562cfd in TypeInstance::deduceType (this=0x8e55d0, sc=0x98b300, 
    tparam=0x8e13c0, parameters=0x8e50a0, dedtypes=0x7fffffffd4c0, 
    wildmatch=0x0) at template.c:3621
3621        TemplateDeclaration *tempdecl =
tempinst->tempdecl->isTemplateDeclaration();

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 07 2013
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11190




This (somewhat less strange) example also makes DMD segfault at the same place:

struct SomeStruct(T) {
    T _value;
    alias _value this;
}

void doSomething(T: ulong)() {
    assert(false);
}

void doSomething(T: string)() {
    assert(false);
}

void doSomething(T: SomeStruct!T)() {
    assert(false);
}

pragma(msg, doSomething!(SomeStruct!ulong)());

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