www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 763] New: Segfault compiling template code on Linux

reply d-bugmail puremagic.com writes:
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.


-- 
Dec 28 2006
next sibling parent Sean Kelly <sean f4.ca> writes:
Correction, this crashes on Win32 as well.
Dec 28 2006
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=763


bugzilla digitalmars.com changed:

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





Fixed DMD 1.00


-- 
Jan 03 2007
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=763






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


-- 
Feb 27 2007