This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [[patch] valarray (was Re: valarray_copy implementation question)


On 11/26/2009 08:51 AM, Christian BRUEL wrote:
> and your assignment proposals:
> myarray[mymask] += valarray<int>(3,0);
> myarray[mymask] += valarray<int>(3,2);
> are NOT guaranteed to work fine since you'd have the array to be of
> size 10 and the argument array of size [0,2]. Note that the size of
> myarray is really 10, it's not the number of true elements that only
> determines the elements to which the operation will apply.
>
> But in anycase, the current trunk behavior of the testcase is
> Segmentation fault (compile with -O0) which is obviously wrong.
>
For sure it doesn't segfault here. It works fine with no memory leaks or
errors. And, note, I don't know about the details of the Standard, isn't
my area, but with the aboe (that is, ..(3,0) for the first assignment
and ..(3,2) for the second), the right hand member makes available
exactly as many elements as are assigned to the left hand elements
corresponding to true booleans, _M_sz, that is. As I see it, the issue
is only whether it makes sense to allow for a right hand data larger
than that, with some elements which end up not being used, that is not
assigned to any left hand slot. I'm not sure whether this is correct,
Gaby may know better.

Paolo.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]