This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Code compiled fine under 2.8.1 but fails to compile under 2.95.1


On Sep 15, 1999, Thomas A Peterson <tap@htc.honeywell.com> wrote:

> We have some code that compiled fine under 2.8.1 but fails to compile
> successfully under 2.95.1. I have included a sample of code below that
> exhibits the problem.

gcc 2.95.1 is correct, the code is ill-formed.  You must either define
the destructor for all specializations and explicitly instantiate it:

template <class T> BalancedTreeNode<T>::~BalancedTreeNode() {}
template BalancedTreeNode<Name>::~BalancedTreeNode();

or just define an explicit specialization: 

template <> BalancedTreeNode<Name>::~BalancedTreeNode() {}

but it may be too late at that point, since the destructor of
BalancedTreeNode<Name> had already been bound to the unspecialized
declaration (even though it was not defined yet), when it compiled the
destructor of class Name, that implicitly referred to it to destruct
the aliasNamespaceNode data member.  So you might prefer to
declare the explicit specialization before defining class Name:

template <> BalancedTreeNode<Name>::~BalancedTreeNode();
class Name
{ ...

-- 
Alexandre Oliva http://www.dcc.unicamp.br/~oliva IC-Unicamp, Bra[sz]il
oliva@{dcc.unicamp.br,guarana.{org,com}} aoliva@{acm.org,computer.org}
oliva@{gnu.org,kaffe.org,{egcs,sourceware}.cygnus.com,samba.org}
** I may forward mail about projects to mailing lists; please use them


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]