This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC 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:
| 
| >I think something is going wrong with types characterized by
| >""non-trivial"" constructors, e.g., doing memory allocation from the heap.
| >
| >Gaby can you look into this?
| >  
| >
| 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...

Yes, you're right.  Anything that puts elements into a valarray being
constructed should use _copy_construct.

-- Gaby


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