Hooray for complex bugs:
struct S { uint x; }
template MakeS(uint x) { const MakeS = S(x); }
struct S2 { alias .MakeS MakeS; }
void f() {
S2 s2;
auto n = s2.MakeS!(0); //////////// XXX
}
$ ldc -c arst.d
0 ldc 0x0000000000cc2bcf
1 ldc 0x0000000000cc321d
2 libpthread.so.0 0x00007f2990cdde80
3 ldc 0x0000000000645ca3 DtoIndexStruct(llvm::Value*, StructDeclaration*, VarDeclaration*) + 99
4 ldc 0x00000000005f5161 DotVarExp::toElem(IRState*) + 385
5 ldc 0x00000000005f5791 AssignExp::toElem(IRState*) + 193
6 ldc 0x0000000000616a74 DtoDeclarationExp(Dsymbol*) + 596
7 ldc 0x00000000005f2231 DeclarationExp::toElem(IRState*) + 65
8 ldc 0x000000000060475c ExpStatement::toIR(IRState*) + 108
9 ldc 0x00000000006048e7 CompoundStatement::toIR(IRState*) + 103
zsh: segmentation fault ldc -c arst.d
The line marked XXX causes the segfault.
A workaround is to use S2.MakeS!(0) instead—i.e. access the template through the struct type instead of the variable.
This has the additional annoyance of breaking with statements in which something like MakeS is accessed from within the struct:
struct S2 {
alias .MakeS MakeS;
void f() {
S2 s2;
with (s2)
auto n = MakeS!(0); // XXX
}
}
The lined marked XXX would ordinarily be fine, but the with (s2) transforms it into s2.MakeS!(0) thus triggering this bug.