| Thread overview | |||||
|---|---|---|---|---|---|
|
October 06, 2006 compiler in infinite loop | ||||
|---|---|---|---|---|
| ||||
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) ); } | ||||
October 06, 2006 Re: compiler in infinite loop | ||||
|---|---|---|---|---|
| ||||
Posted in reply to rm | 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) ); } | |||
October 06, 2006 Re: compiler in infinite loop | ||||
|---|---|---|---|---|
| ||||
Posted in reply to rm Attachments: | 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 | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply