bad template instantiate(?)
Steven Parkes
parkes@sierravista.com
Sun Aug 9 15:32:00 GMT 1998
Appended is a short file that doesn't compile with either the latest egcs
or latest gcc2 snapshot. It does build with testgcc-2.8.00 980118.
When compiled with stage2/xgcc -W -Bstage2/ -c y.C
it gives
y.C: In instantiation of `TypeIDInit<UUId>::info':
y.C:40: instantiated from `TypeIDInit<UUId>::TypeIDInit<UUId>()'
y.C:65: instantiated from here
y.C:31: redefinition of `struct TypeInfo TypeIDInit<UUId>::info'
y.C:31: `struct TypeInfo TypeIDInit<UUId>::info' previously defined here
it seems to be getting confused trying to follow instantiation dependences.
Perhaps some sort of ill-timed recursion?
typedef unsigned int size_t;
class UUId {};
template <class T> class MetaClass;
class TypeInfo;
struct MetaClassGeneric
{
MetaClassGeneric( TypeInfo& );
};
struct TypeInfo
{
void (*constructor)( void* );
void initialize( void* );
};
template <class T>
class TypeIDInit {
public:
TypeIDInit();
static void initialize();
static TypeInfo info;
static int storage[];
static void metaclassConstructor( void* );
};
template <class T>
TypeInfo TypeIDInit<T>::info =
{
TypeIDInit<T>::metaclassConstructor
};
template <class T>
inline
TypeIDInit<T>::TypeIDInit()
{
info.initialize(storage);
}
template <class T>
class NameInfo : public MetaClassGeneric {
public:
NameInfo()
: MetaClassGeneric( TypeIDInit<T>::info ) {}
};
class MetaClass<UUId>
: public NameInfo<UUId>
{
};
extern "C++"
inline void *operator new(size_t, void *place) throw() { return place; }
template <class T>
void
TypeIDInit<T>::metaclassConstructor( void* place )
{
new ( place ) MetaClass<T>;
}
template class TypeIDInit<UUId> ;
More information about the Gcc-bugs
mailing list