This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: valarray_copy implementation question
Hi again,
thanks Christian for your feedback.
> The case I have is for SH4. I'll try to reduce and reproduce on x86.
>
> However, reading the code, the scenario is easy to describe. I you
> have a bool Array with only false value the while (! *__ok) loop while
> go forever. so a check on the count is needed.
>
> As an illustration, the code could be rewritten as
>
> _Tp* __q (__b._M_data);
> bool* __ok (__m._M_data);
> for (_Tp* __p = __a._M_data; __p < __a._M_data+__n;
> ++__p, ++__ok, ++__q)
> {
> if (*__ok)
> *__q = *__p;
> }
>
> but that implies that the size if each array is __n, which is not
> apparently the original Standard interpretation.
Indeed, I was also thinking along the same lines, the change would be
straightforward. In the meanwhile I also checked that another widespread
implementation indeed uses if not while and does the same thing otherwise.
Now, I would just go ahead and do the change, I only want to confirm
with Gaby that *all those* 'while (! *__ok)' are in the same ballpark,
because, as was already trying to say, actually we have a few, in
valarray_array.tcc and also in valarray_array.h as _Array_augmented_*
For sure I'm seeing a few in that alternate implementation I have at hand...
Thanks,
Paolo.