bug in template instantiation
Carlo Pescio
pescio@acm.org
Sun Dec 21 11:04:00 GMT 1997
I'm trying to port to egcs (actually mingw32-egcs) some code I've developed
under KAI C++. I'm encountering several problems with templates.
The minimal code below shows one of them (unfortunately, a real showstopper
for me). The template instantiation never terminates because F::dim is not
evaluated, so it never goes to 0 (instead, I get a sequence of F::dim -1 -1
-1 -1 ... in error messages).
Something similar happens also when you access a typedef in F instead of an
enum.
I guess it's worthy a bug fix (or maybe is already fixed but not in
mingw32-ecgs?).
Thanks for your time and your excellent work with egcs,
Carlo
template< int i > struct T :
public T< i-1 >
{
} ;
template<> struct T< 0 >
{
} ;
template< class F > struct T1 :
public T< F::dim >
// here is the problem. F::dim never
// gets evaluated during instantiation,
// so instantiation itself cannot terminate.
// It works fine if you use a literal instead,
// as in (e.g.) public T< 3 >
{
} ;
template< int i > struct S
{
enum { dim = i } ;
} ;
int main()
{
T1< S< 4 > > t ;
return( 0 ) ;
}
+------------------------------------------------------------------------+
| Dr. Carlo Pescio Email: pescio@acm.org |
| Eptacom Consulting pescio@computer.org |
| Via B. Forte 2-3 pescio@programmers.net |
| 17100 Savona - ITALY pescio@tin.it |
| Fax: +39-19-854761 Home: http://www.programmers.net/artic/Pescio |
+------------------------------------------------------------------------+
More information about the Gcc-bugs
mailing list