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: slice valarrays with std::string -> segfault


Paolo Carlini <pcarlini@suse.de> writes:

| Paolo Carlini wrote:
| 
| >Gaby, I see __valarray_copy used (instead of __valarray_copy_construct)
| >by the conversion constructor from slice_array for any type T: i.e., no
| >placement new, that cannot possibly work a T such as 'struct element' in
| >the posted snippet. Indeed, lots and lots of errors from valgrind...
| >  
| >
| Just to explain concretely what I mean, the attached quick and dirty
| hack avoids the Seg fault and makes valgrind happy. I think it tells us
| something...

I just saw this message.  As said in previous mails, your analysis is
correct that the use of _copy instead of _copy_construct was
thoughtless -- other constructors carefully use _copy_construct.

[...]

| +    __valarray_construct(_Array<_Tp> __a, size_t __n, size_t __s, _Array<_Tp> __b)

Can we do without this additional layer?
Otherwise, the patch is correct with that change.

Thanks!

-- Gaby


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