Re: RE : [ROOT] TArrayD

From: Fons Rademakers (Fons.Rademakers@cern.ch)
Date: Tue Apr 01 2003 - 01:18:46 MEST


Sorry but can do nothing about the break point. Ask Microsoft for a fix.

Cheers, Fons.


On Mon, 2003-03-31 at 09:18, GENTIT Francois-Xavier DAPNIA wrote:
> Mr Rademakers,
> The reason why I tried these 2 lines of code:
> 
> TArrayD *a = new TArrayD(10);
> delete [] a->fArray;
> 
> is because the following 2 lines of code:
> 
> TArrayD *a = new TArrayD(10);
> delete a;
> 
> give a problem in Visual C++.NET. Visual C++.NET sees a breakpoint at the
> second line, even if the user has not put a breakpoint. Imagine the
> annoyance if this happens in a loop to be done 1000 times! Since this did
> not happened with Visual C++ 6.0, I first thought that it was a bug in
> Visual C++.NET. But the fact that the perfectly valid C++ line: 
> 
> delete [] a->fArrayD;
> 
> crashes on all compilers and all machines indicates it is a problem of ROOT.
> 
> 
> Gentit François-Xavier
> DAPNIA/SPP CEA Saclay
> http://gentit.home.cern.ch/gentit/
> 
> 
> 
> -----Message d'origine-----
> De : Fons Rademakers [mailto:Fons.Rademakers@cern.ch] 
> Envoyé : vendredi 28 mars 2003 18:30
> À : Brett Viren
> Cc : GENTIT Francois-Xavier DAPNIA; 'Club ROOT "(roottalk@pcroot.cern.ch)'"
> Objet : Re: [ROOT] TArrayD
> 
> The fact that you can do this does not mean that it should work. Why
> would you like to do this, instead of using the dtor? For these simple
> classes all data members are public for easy access, but you should not
> do silly things. You can also pass a 0 to strlen and get a segv.
> 
> -- Fons
> 
> 
> On Fri, 2003-03-28 at 16:41, Brett Viren wrote:
> > GENTIT Francois-Xavier  DAPNIA writes:
> >  > Dear Rooters,
> >  > 
> >  > The following 2 lines of code cause a crash of ROOT when compiled (not
> in
> >  > CINT) :
> >  > 
> >  >  
> >  > 
> >  >   TArrayD *a = new TArrayD(10);
> >  > 
> >  >   delete [] a->fArray;
> >  > 
> >  >  
> >  > 
> >  > I have tried them on Linux RedHat with ROOT 3.05.02 and
> >  > 
> >  > On Windows XP, Visual C++.NET, ROOT 3.05.03
> >  > 
> >  >  
> >  > 
> >  > Both cases crash. fArray being public, it should work? Is it a bug or a
> >  > feature?
> > 
> > Having it public is bad, imo.  But anyways, if you are going to delete
> > it this you had probably do what TArrayD does internally:
> > 
> >    TArrayD *a = new TArrayD(10);
> >  
> >    delete [] a->fArray;
> >    a->fArray = 0;
> > 
> > Or, looking at the implementation you could replace those last two
> > lines with:
> > 
> >    a->Adopt(0,0);
> > 
> > 
> > -Brett.
-- 
Org:    CERN, European Laboratory for Particle Physics.
Mail:   1211 Geneve 23, Switzerland
E-Mail: Fons.Rademakers@cern.ch              Phone: +41 22 7679248
WWW:    http://root.cern.ch/~rdm/            Fax:   +41 22 7679480



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:10 MET