This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Code compiled fine under 2.8.1 but fails to compile under 2.95.1
- To: Thomas A Peterson <tap at htc dot honeywell dot com>
- Subject: Re: Code compiled fine under 2.8.1 but fails to compile under 2.95.1
- From: Alexandre Oliva <oliva at lsd dot ic dot unicamp dot br>
- Date: 15 Sep 1999 20:35:50 -0300
- Cc: gcc-bugs at gcc dot gnu dot org
- References: <199909151630.LAA01466@wocket.htc.honeywell.com>
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