www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8200] New: DMD segfault: template aliasing result of map

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8200

           Summary: DMD segfault: template aliasing result of map
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Mac OS X
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: peter.alexander.au gmail.com


--- Comment #0 from Peter Alexander <peter.alexander.au gmail.com> 2012-06-05
13:35:48 PDT ---
---------
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 05 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8200



--- Comment #1 from Peter Alexander <peter.alexander.au gmail.com> 2012-06-05
13:43:10 PDT ---
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 ()

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 05 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8200



--- Comment #2 from Kenji Hara <k.hara.pg gmail.com> 2012-06-05 18:59:01 PDT ---
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());
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 05 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8200


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug yahoo.com.au
         OS/Version|Mac OS X                    |All


--- Comment #3 from Don <clugdbug yahoo.com.au> 2012-08-14 01:32:07 PDT ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 14 2012