Re: Bug in TObjArray?

From: Vassili Maroussov <Vassili.Maroussov_at_cern.ch>
Date: Fri, 17 Sep 2010 16:21:24 +0200


Hi Axel,

I got your point... although I never thought to use TObjArray with "placement new" (TClonesArray seems better suited for that, since it provides pre-allocated memory). Now have to remember that neither TObjArray[] nor TObjArray.At() is checking bounds at "read access" :(

Cheers,

Vassili

On 09/17/2010 02:40 PM, Axel Naumann wrote:
> Hi Vassili,
>
> yes, that's on purpose, think of
>
> new (Arr[0]) TObject;
>
> Cheers, Axel.
>
>
> Vassili Maroussov wrote on 09/17/2010 02:31 PM:
>
>> Dear ROOTers,
>>
>> I'm wondering why TObjArray is designed in such a way that an attempt to
>> access the [fLowerBound] element of an empty TObjArray doesn't cause any
>> error (please see the example attached). Moreover, it has a rather
>> unpleasant side effect: after the access GetEntriesFast() reports that
>> the array isn't empty any more. Is it done purposely?
>>
>> Regards,
>>
>> Vassili
>>
>>
Received on Fri Sep 17 2010 - 16:21:28 CEST

This archive was generated by hypermail 2.2.0 : Fri Sep 17 2010 - 17:50:01 CEST