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



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




13:43:10 PDT ---
Callstack from gdb: Looks like infinite recursive call.

Lots of VarExp::interpret() (!!!)
...






























-- 
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




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



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