struct Zug(int Z){ const void * bahn = Bug4093!(0).hof.bahn; } struct Bug4093(int Q){ Zug!(0) hof; } const a = Zug!(0).bahn; ==== crash.d(220): Error: 'this' is only defined in non-static member functions, not crash crash.d(220): Error: this for hof needs to be type Bug4093 not type int
This bug is completely fixed by the patch to 4094. However, I think this bug does reveal another problem which is also worth fixing. The segfault itself can also be fixed with this patch to expression.c line 280. The error message it gives is nonsense (so the patch to bug 4094 fixes that), but I think adding more ErrorExps is no bad thing, and may prevent another future crash. e1->error("this for %s needs to be type %s not type %s", var->toChars(), ad->toChars(), t->toChars()); + e1 = new ErrorExp(); }
Fixed DMD2.044
The test code in the original comment does not compile on DMD2.048 (Error: variable hof cannot be read at compile time) and causes a segfault in DMD1.063. Is this bug really fixed?
Although this bug is fixed in D2, it is NOT fixed for D1 (where it generates a stack overflow).
(In reply to comment #4) > Although this bug is fixed in D2, it is NOT fixed for D1 (where it generates a > stack overflow). Don't know why I thought that. This bug never existed on D1. The stack overflow only occurs on a debug version of DMD; on a release DMD, it generates a "recursive template expansion" error. There's no difference between D1 and D2; change the 'const void *' to 'enum void *' to see the D1 behaviour in D2.