ambiguous TObject::delete

From: ZVYAGIN (ZVYAGIN@mx.ihep.su)
Date: Sun Oct 17 1999 - 06:34:31 MEST


Dear ROOTers,

take a look at this simple code (file a.c):

#include "TObject.h"
#include "TNamed.h"
class A:           virtual public TObject { public: ~A(void); A(void){} };
class B: public A, virtual public TNamed  { public: ~B(void); B(void){} };
A::~A(void) {}
B::~B(void) {}

class TObject must be declared as virtual base class to remove double 
copy of TObject in A and B.

When I try to compile this code (root-2.21-08 and root-2.23-04) I get the 
same error messages:

$ g++ -I $ROOTSYS/include -c a.c
a.c: In method `B::~B()':
a.c:8: request for member `operator delete' is ambiguous
/usr/local/root/include/TObject.h:162: candidates are: static void 
TObject::operator delete(void *, void *)
/usr/local/root/include/TObject.h:159: candidates are: static void 
TObject::operator delete(void *)
/usr/local/root/include/TObject.h:162:                 static void 
TObject::operator delete(void *, void *)
/usr/local/root/include/TObject.h:159:                 static void 
TObject::operator delete(void *)

These are lines 159 and 162 of file TObject.h:
   void     operator delete(void *ptr);
   void     operator delete(void *ptr, void *vp);

These are lines with delete operator declarations from file "new" 
corresponding to gcc-2.95.1:
void operator delete (void *) throw();
void operator delete[] (void *) throw();
void operator delete (void *, const std::nothrow_t&) throw();
void operator delete[] (void *, const std::nothrow_t&) throw();

The declaration 
   void     operator delete(void *ptr, void *vp);
is not present in "new" file.

File TObject.cxx contains the code:

#ifdef R__PLACEMENTDELETE
//______________________________________________________________________________
void TObject::operator delete(void *ptr, void *vp)
{
   // Only called by placement new when throwing an exception.
   if (ptr && vp) { }
}
#endif

So this is empty operator. Does ROOT need it really?

With best wishes,
Alexander Zvyagin.



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:41 MET