D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 11190 - DMD segfaults in template resolution with "alias this"
Summary: DMD segfaults in template resolution with "alias this"
Status: RESOLVED DUPLICATE of issue 11518
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: ice
Depends on:
Blocks:
 
Reported: 2013-10-07 10:13 UTC by blm768
Modified: 2013-11-21 18:32 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description blm768 2013-10-07 10:13:58 UTC
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();
Comment 1 blm768 2013-10-07 10:25:57 UTC
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)());
Comment 2 Kenji Hara 2013-11-21 18:32:46 UTC

*** This issue has been marked as a duplicate of issue 11518 ***