October 04, 2006 infinite loop in gdc-0.19 with tempaltes | ||||
|---|---|---|---|---|
| ||||
On Gentoo (gdc-0.19), the following does land gdc in an infinite loop. Don't know whether it does the same with the dmd compiler.
private import std.stdio;
template TFoo(int v : 1)
{
const int TFoo = 1;
}
template TFoo(int v)
{
const int TFoo = v * TFoo!(v-1).TFoo;
}
void main()
{
std.stdio.writefln(TFoo!(5).TFoo);
}
changing the const int to an enum declaration does work though.
grtz,
roel
| ||||
November 25, 2006 Re: infinite loop in gdc-0.19 with tempaltes | ||||
|---|---|---|---|---|
| ||||
Posted in reply to rm Attachments: | rm schrieb am 2006-10-04: > On Gentoo (gdc-0.19), the following does land gdc in an infinite loop. Don't know whether it does the same with the dmd compiler. > > private import std.stdio; > > template TFoo(int v : 1) > { > const int TFoo = 1; > } > > template TFoo(int v) > { > const int TFoo = v * TFoo!(v-1).TFoo; > } > > void main() > { > std.stdio.writefln(TFoo!(5).TFoo); > } > > changing the const int to an enum declaration does work though. Added to DStress as http://dstress.kuehne.cn/nocompile/t/template_48_A.d http://dstress.kuehne.cn/compile/t/template_48_B.d Thomas | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply