Bug 763 – Segfault compiling template code on Linux
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2006-12-28T15:28:00Z
Last change time
2014-02-15T13:19:06Z
Keywords
ice-on-valid-code
Assigned to
bugzilla
Creator
sean
Comments
Comment #0 by sean — 2006-12-28T15:28:56Z
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.