www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript

D.gnu - infinite loop in gdc-0.19 with tempaltes

↑ ↓ ← rm <roel.mathys gmail.com> writes:
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
Oct 04 2006
↑ ↓ → Thomas Kuehne <thomas-dloop kuehne.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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 -----BEGIN PGP SIGNATURE----- iD8DBQFFaILxLK5blCcjpWoRAuuYAJ405a2ROUJVqY6O9NMIVwztVKRdigCeOKrG 392ncD9mibHpdjdwo1apbUA= =61KY -----END PGP SIGNATURE-----
Nov 25 2006