Re: [ROOT] Little hint about pointers

From: Christian Holm Christensen (cholm@hehi03.nbi.dk)
Date: Tue Nov 20 2001 - 21:09:40 MET


Hi all, 

I didn't get this message to roottalk, so here goes. 

Hi Alberto, 

On Tue, 20 Nov 2001 16:11:19 +0100
Alberto Pulvirenti <alberto.pulvirenti@CT.INFN.IT> wrote
concerning "Re: [ROOT] Little hint about pointers":
> Ok, Chhristian, I saw you're right.
> But now rises another question:
> 
> if I leave the C2 destructor void, and I invoke the TObjArray::Delete(), 
> what will happen to the object pointed by the C2 ? It seems that the 
> TObjArray::Delete doesn't remove it...

Well, as the attached (expanded) example show, it does call the DTOR
of class C1. For what ever reason, the underlying TObject array is
still there :-(.  This seems extreemly odd.  The program should
SIGSEGV. 

I tried this on Red Hat 6.2 (GCC 2.91) and Red Hat 7.1 ('GCC 2.96')
using ROOT 3.02/00. I also tried on Red Hat 6.2 and ROOT 3.02/04 with
the same result. 

However, on Debian GNU/Linux 2.1 (GCC 2.91) with ROOT 2.23/10, the
program does get a SIGSEGV, as I believe it should.  

Maybe I've misunderstood something in the ANSI/ISO C++ standard, that
makes this behaviour alright, but I dont think so. I believe this is a
question for the ROOT team.  

It seems that one gets a handle to the newly allocated TObjects
resulting from TObjArray::Init in TObjArray::Delete.  That's my guess
anyway.  

This issues, I believe goes for all subclasses of TCollection,
including THashList. 

Yours,

Christian Holm Christensen -------------------------------------------
Address: Sankt Hansgade 23, 1. th.           Phone:  (+45) 35 35 96 91 
         DK-2200 Copenhagen N                Cell:   (+45) 28 82 16 23
         Denmark                             Office: (+45) 353  25 305 
Email:   cholm@nbi.dk                        Web:    www.nbi.dk/~cholm





This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:51:09 MET