Bug 8200 – DMD segfault: template aliasing result of map

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
All
Creation time
2012-06-05T13:35:00Z
Last change time
2013-11-21T18:49:30Z
Assigned to
nobody
Creator
peter.alexander.au

Comments

Comment #0 by peter.alexander.au — 2012-06-05T13:35:48Z
--------- import std.algorithm; struct Range { @property int front() { return 0; } void popFront() {} enum bool empty = false; int dummy = 0; } void foo(alias A)() {} void main() { foo!(map!"a"(Range()))(); } --------- % dmd test.d zsh: segmentation fault dmd test.d --------- I haven't managed to reduce it beyond this. This happens with DMD 2.059 and also from DMD 2.060 head.
Comment #1 by peter.alexander.au — 2012-06-05T13:43:10Z
Callstack from gdb: Looks like infinite recursive call. Lots of VarExp::interpret() (!!!) ... #104761 0x001512fa in VarExp::interpret () #104762 0x001512fa in VarExp::interpret () #104763 0x001512fa in VarExp::interpret () #104764 0x001512fa in VarExp::interpret () #104765 0x001512fa in VarExp::interpret () #104766 0x001512fa in VarExp::interpret () #104767 0x001512fa in VarExp::interpret () #104768 0x001512fa in VarExp::interpret () #104769 0x001512fa in VarExp::interpret () #104770 0x00152bf6 in BinExp::interpretAssignCommon () #104771 0x00155c6f in AssignExp::interpret () #104772 0x00152445 in CommaExp::interpret () #104773 0x0015a1d2 in CallExp::interpret () #104774 0x0014fb0a in ReturnStatement::interpret () #104775 0x001481c6 in CompoundStatement::interpret () #104776 0x001481c6 in CompoundStatement::interpret () #104777 0x00157de5 in FuncDeclaration::interpret () #104778 0x00159f71 in CallExp::interpret () #104779 0x000f9d8f in CallExp::optimize () #104780 0x001280a0 in TemplateInstance::semanticTiargs () #104781 0x001283df in TemplateInstance::semanticTiargs () #104782 0x0009ff31 in CallExp::semantic () #104783 0x001171b1 in ExpStatement::semantic () #104784 0x0011e86f in CompoundStatement::semantic () #104785 0x000a89d2 in FuncDeclaration::semantic3 () #104786 0x000dbb12 in Module::semantic3 () #104787 0x000d82f8 in tryMain () #104788 0x0000275f in _start () #104789 0x0000268d in start ()
Comment #2 by k.hara.pg — 2012-06-05T18:59:01Z
May reduced test case. In 2.060head, following code compilation doesn't finish. (segfault doesn't occurs) Platform: Windows7 64bit template map(alias fun) { auto map(R)(R r) { struct Result { R _input; // If remove this ctor, bug disappears version(all) this(R input) { _input = input; } //@property bool empty() //{ // return _input.empty; //} @property auto ref front() { return fun(_input.front); } //void popFront() //{ // _input.popFront(); //} } return Result(r); } } struct Range { //enum bool empty = true; @property int front() { return 0; } //void popFront() {} int dummy = 0; } void main() { enum r = map!(a=>a)(Range()); }
Comment #3 by clugdbug — 2012-08-14T01:32:07Z
Seems fixed. I can reproduce the segfault with 2.059 but not git head. May have been fixed by one of the CTFE patches around 19 June.