template-depth

Phil Edwards pedwards@disaster.jaj.com
Tue Dec 26 12:41:00 GMT 2000


On Mon, Dec 25, 2000 at 10:29:02AM -0800, Mike Stump wrote:
> > Date: Sun, 24 Dec 2000 21:55:41 -0500
> > From: Phil Edwards <pedwards@disaster.jaj.com>
> > To: Mike Stump <mrs@windriver.com>
> 
> > That sounds like a library bug, or rather a design problem.  Any idea
> > where in the library this occurs?
> 
> Yes, but I don't feel it is a bug.

I'm still waiting to hear where it occurs.  :-)  But from this bit...


> > Why limit NN to be low arbitrarily?
> 
> Good question.  Hint, C++ is soo powerful, that it is turing complete
> at compile time.

...I'm assuming you're talking about the compile-time computations
performed during compilation of the bit-counting templates for locales?
(I don't recall compile-time computations being used anywhere else in the
library, but I haven't specifically looked for them recently, esp. not in
the numerics code.)

Yes, I've read Veldhuizen's papers also; and I also realize the implications
of Turing-complete languages.  :-)

I don't have access to the library sources right now, but I recall a code
comment that those instantiations only took a half-dozen levels...?


> :-) Now, what happens when the user accidentally gets his
> simple `program' into an infinite loop?

If it's infinite, it's going to die regardless of what gets used for a
maximum depth limit.

I don't feel that helping infinitely-nested templates crash earlier justifies
making correctly-nested templates more difficult to compile; forcing the
user to add -ftemplate-depth-NN is just another hoop to jump through.

Maybe I wasn't clear before:  I'm not suggesting we remove the maximum
depth limit altogether.  I'm just suggesting we do more than inch it
upwards slowly.


Phil

-- 
pedwards at disaster dot jaj dot com  |  pme at sources dot redhat dot com
devphil at several other less interesting addresses in various dot domains
The gods do not protect fools.  Fools are protected by more capable fools.


More information about the Gcc-patches mailing list