Re: TMath::Sort :: warning if n < array size

From: Adrian Sevcenco <Adrian.Sevcenco_at_cern.ch>
Date: Sun, 21 Aug 2011 17:43:27 +0300


On 08/21/11 16:58, Axel Naumann wrote:
> Hi Adrian,

Hi!

> Thanks for your suggestion. We can't determine the sizeof(index), all we
> have is a pointer (not an array), and that would just return you
> sizeof(void*).

hmm .. that would mean that the arrays that are the arguments are deprecated somewhere somehow to (void*)

> A recommendation: you could have used valgrind to find this problem in
> your usage of Sort().

well, this is how i found out my problem in my code (i did some copy paste of an sort and i forgot to adjust the number of elements..)

Thanks,
Adrian

>
> Cheers, Axel.
>
>
> On 8/21/11 1:29 AM, Adrian Sevcenco wrote:

>> Hi! I was wondering if would be useful (for me it would because i just
>> had some headaches because of this) to have a warning in case that
>> either (this arguments related to [1]):
>> 1. n < sizeof(index)/sizeof(index[0])
>> or
>> 2. sizeof(index) < sizeof(a)
>>
>> and definitely an error (if it is needed..) for
>> n > sizeof(a)
>>
>> Thanks,
>> Adrian
>>
>> [1]. http://root.cern.ch/root/html/src/TMath.h.html#YYNCbB

>

Received on Sun Aug 21 2011 - 16:42:27 CEST

This archive was generated by hypermail 2.2.0 : Sun Aug 21 2011 - 23:50:01 CEST