digitalmars.D - compiler in infinite loop
- rm <roel.mathys gmail.com> Oct 06 2006
- rm <roel.mathys gmail.com> Oct 06 2006
- Thomas Kuehne <thomas-dloop kuehne.cn> Oct 06 2006
hi,
this code puts the dmd compiler (v168) into an infinite loop,
and it's caused by having a member in this template that has the same
name as the template.
bye,
roel
===============================================
private import std.stdio;
template TValue(int i:1)
{
pragma(msg,"last instantiation!!!");
const int TValue = 1;
}
template TValue(int i)
{
pragma(msg,"instantiating...");
const int TValue = i * TValue!(i-1);
}
void main()
{
writefln( TValue!(3) );
}
Oct 06 2006
but this will work,
so it's the specialisation that is troubling
bye,
rm
===================================================================
private import std.stdio;
/*template TValue(int i:1)
{
pragma(msg,"last instantiation ... 1 !!!");
const int TValue = 1;
}*/
template TValue(int i)
{
static if (i==2) pragma(msg,"instantiating ... 2");
static if (i==3) pragma(msg,"instantiating ... 3");
static if (i==4) pragma(msg,"instantiating ... 4");
static if (i==5) pragma(msg,"instantiating ... 5");
static if (i==1)
const int TValue = 1;
else
const int TValue = i * TValue!(i-1);
}
void main()
{
writefln( TValue!(5) );
}
Oct 06 2006
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 rm schrieb am 2006-10-06:hi, this code puts the dmd compiler (v168) into an infinite loop, and it's caused by having a member in this template that has the same name as the template. bye, roel =============================================== private import std.stdio; template TValue(int i:1) { pragma(msg,"last instantiation!!!"); const int TValue = 1; } template TValue(int i) { pragma(msg,"instantiating..."); const int TValue = i * TValue!(i-1); } void main() { writefln( TValue!(3) ); }
Known issue: http://d.puremagic.com/issues/show_bug.cgi?id=351 Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFFJqUsLK5blCcjpWoRAgA5AJsFbPLVZIj07gs+9kNk+EHpsuMfgACfegPB JwxjmWP6kYuZn8gBpZqwqO8= =Rohi -----END PGP SIGNATURE-----
Oct 06 2006









rm <roel.mathys gmail.com> 