This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: bad template instantiate
- To: egcs-bugs at cygnus dot com
- Subject: Re: bad template instantiate
- From: Steven Parkes <parkes at sierravista dot com>
- Date: Wed, 12 Aug 1998 14:11:14 -0700
- Cc: jason at cygnus dot com
- Organization: Sierra Vista Research, Inc.
I think I've isolated the change that caused g++ to start failing on
our code. It fails with egcs-1.0.1; egcs-1.0 doesn't bootstrap on
i386-pc-sunos5 which is my test platform.
The code does work with gcc-2.8.0 but fails with 2.8.1, so I've been
looking that the cp/ChangeLog for that period.
If looks like it was a change to instantiate_decl made back in December.
if (! pattern_defined
|| (TREE_CODE (d) == FUNCTION_DECL && ! DECL_INLINE (d)
&& (! DECL_INTERFACE_KNOWN (d)
|| ! DECL_NOT_REALLY_EXTERN (d)))
/* Kludge: if we compile a constructor in the middle of processing a
toplevel declaration, we blow away the declspecs in
temp_decl_obstack when we call permanent_allocation in
finish_function. So don't compile it yet. */
|| (TREE_CODE (d) == FUNCTION_DECL && ! nested && ! at_eof))
{
add_pending_template (d);
goto out;
}
was changed to
/* Reject all external templates except inline functions. */
if (DECL_INTERFACE_KNOWN (d)
&& ! DECL_NOT_REALLY_EXTERN (d)
&& ! (TREE_CODE (d) == FUNCTION_DECL && DECL_INLINE (d)))
goto out;
/* Defer all templates except inline functions used in another function. */
if (! pattern_defined
|| (! (TREE_CODE (d) == FUNCTION_DECL && DECL_INLINE (d) && nested)
&& ! at_eof))
{
add_pending_template (d);
goto out;
}
If I back out this change, things work okay. Of course, this may not
actually be the error; it may just be masking something else.
I'm not clear yet on what the change does ... but I can look at it if
nobody else gets a chance.
typedef unsigned int size_t;
class UUId {};
template class MetaClass;
class TypeInfo;
struct MetaClassGeneric
{
MetaClassGeneric( TypeInfo& );
};
struct TypeInfo
{
void (*constructor)( void* );
void initialize( void* );
};
template
class TypeIDInit {
public:
TypeIDInit();
static void initialize();
static TypeInfo info;
static int storage[];
static void metaclassConstructor( void* );
};
template
TypeInfo TypeIDInit::info =
{
TypeIDInit::metaclassConstructor
};
template
inline
TypeIDInit::TypeIDInit()
{
info.initialize(storage);
}
template
class NameInfo : public MetaClassGeneric {
public:
NameInfo()
: MetaClassGeneric( TypeIDInit::info ) {}
};
class MetaClass
: public NameInfo
{
};
extern "C++"
inline void *operator new(size_t, void *place) throw() { return place; }
template
void
TypeIDInit::metaclassConstructor( void* place )
{
new ( place ) MetaClass;
}
template class TypeIDInit ;