Bug 4093 – Segfault(interpret.c): with recursive struct templates

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2010-04-15T11:41:00Z
Last change time
2015-06-09T01:27:38Z
Keywords
ice-on-invalid-code, patch
Assigned to
nobody
Creator
clugdbug

Comments

Comment #0 by clugdbug — 2010-04-15T11:41:19Z
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
Comment #1 by clugdbug — 2010-04-20T01:39:08Z
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(); }
Comment #2 by clugdbug — 2010-05-05T19:10:53Z
Fixed DMD2.044
Comment #3 by siegelords_abode — 2010-09-05T08:57:10Z
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?
Comment #4 by clugdbug — 2011-04-28T06:20:52Z
Although this bug is fixed in D2, it is NOT fixed for D1 (where it generates a stack overflow).
Comment #5 by clugdbug — 2011-12-23T15:16:04Z
(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.