This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/29688] resize initializes whole array
- From: "pcarlini at suse dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 3 Nov 2006 00:08:20 -0000
- Subject: [Bug libstdc++/29688] resize initializes whole array
- References: <bug-29688-13504@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #4 from pcarlini at suse dot de 2006-11-03 00:08 -------
(In reply to comment #3)
> Subject: Re: resize initializes whole array
>
> There is no argument against the ISO standard, but to a non C/C++ programmer
> it seems a waist of time to reallocate the array and initialize it when one
> wants to add something to an array. Some other compilers will copy the
> existing data into the newly allocated space which seems more in line with
> the text book.
I don't know. We are definitely implementing the ISO C++ Standard, and, by the
way, many details in Stroustrup' books, predating the Standard, are know to be
slightly different. I will also add that valarray is *very* special - its
design was motivated by considerations of highest performance on superscalar
architectures, etc. - for example vector::resize behaves in a completely
different way, which probably you like better.
> The application will be changed to avoid the loss of data on a resize of
> arrays, which is a better idea anyway. Thanks for the speedy reply.
For portability, that is the safe thing to do, yes, I agree.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29688