Thread overview
[Issue 763] New: Segfault compiling template code on Linux
Dec 28, 2006
d-bugmail
Dec 28, 2006
Sean Kelly
Jan 04, 2007
d-bugmail
Feb 27, 2007
d-bugmail
December 28, 2006
http://d.puremagic.com/issues/show_bug.cgi?id=763

           Summary: Segfault compiling template code on Linux
           Product: D
           Version: 0.177
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: sean@f4.ca


This doesn't appear to be a problem on Win32.

----------

module a;

private
{
    struct IsEqual( T )
    {
        bool opCall( T p1, T p2 )
        {
            return p1 == p2;
        }
    }

     template ElemTypeOf( T )
    {
        alias typeof(T[0]) ElemTypeOf;
    }
}

template find_( Elem, Pred = IsEqual!(Elem) )
{
    size_t fn( Elem[] buf, Elem pat, Pred pred = Pred.init )
    {
        return buf.length;
    }
}

template find( Buf, Pat )
{
    size_t find( Buf buf, Pat pat )
    {
        return find_!(ElemTypeOf!(Buf)).fn( buf, pat );
    }
}

----------

module b;

private import a;

int fn()
{
    return find( "123", '2' );
}

----------

Simply run "dmd a.d b.d" and watch the fireworks.  This appears to be related to the default final parameter, Pred.


-- 

December 28, 2006
Correction, this crashes on Win32 as well.
January 04, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=763


bugzilla@digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




------- Comment #2 from bugzilla@digitalmars.com  2007-01-03 22:15 -------
Fixed DMD 1.00


-- 

February 27, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=763





------- Comment #3 from thomas-dloop@kuehne.cn  2007-02-27 10:47 -------
Added to DStress as http://dstress.kuehne.cn/compile/t/template_55_A.d http://dstress.kuehne.cn/nocompile/t/template_55_B.d http://dstress.kuehne.cn/nocompile/t/template_55_C.d


--