* [Bug libstdc++/32618] std::vector calls uneccessary constructors instead of inplace construction of first object
2007-07-04 0:46 [Bug libstdc++/32618] New: std::vector calls uneccessary constructors instead of inplace construction of first object oliver at kfs dot org
@ 2007-07-04 0:52 ` pinskia at gcc dot gnu dot org
2007-07-04 1:03 ` pcarlini at suse dot de
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-07-04 0:52 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2007-07-04 00:52 -------
> The optimization I am suggesting would produce the following [approximate]
is wrong. You have to bind a constant reference to a temp variable and then
doing a copy as you do a[0] = b;
So the optimization for resize is wrong and incorrect.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32618
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug libstdc++/32618] std::vector calls uneccessary constructors instead of inplace construction of first object
2007-07-04 0:46 [Bug libstdc++/32618] New: std::vector calls uneccessary constructors instead of inplace construction of first object oliver at kfs dot org
2007-07-04 0:52 ` [Bug libstdc++/32618] " pinskia at gcc dot gnu dot org
@ 2007-07-04 1:03 ` pcarlini at suse dot de
2007-07-04 4:27 ` oliver at kfs dot org
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pcarlini at suse dot de @ 2007-07-04 1:03 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from pcarlini at suse dot de 2007-07-04 01:02 -------
I suspect Oliver is raising a good point, in very general terms. Before going
into the details, I want to make sure he knows this proposal, which is likely
to make into C++0x, in some form:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2217.pdf
--
pcarlini at suse dot de changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |WAITING
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32618
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug libstdc++/32618] std::vector calls uneccessary constructors instead of inplace construction of first object
2007-07-04 0:46 [Bug libstdc++/32618] New: std::vector calls uneccessary constructors instead of inplace construction of first object oliver at kfs dot org
2007-07-04 0:52 ` [Bug libstdc++/32618] " pinskia at gcc dot gnu dot org
2007-07-04 1:03 ` pcarlini at suse dot de
@ 2007-07-04 4:27 ` oliver at kfs dot org
2007-07-04 4:34 ` pinskia at gcc dot gnu dot org
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: oliver at kfs dot org @ 2007-07-04 4:27 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from oliver at kfs dot org 2007-07-04 04:27 -------
Andrew, currently it seems to work like this (pseudo code warning):
T* newSpace = alloc(newSize);
int i = 0 ;
for ( ; i < size ; ++i ) {
newSpace[i].constructor(oldSpace[i]) ;
}
const T defaultInstance ;
for ( ; i < newSize ; i++ ) {
newSpace[i].constructor(defaultInstance) ;
}
What I'm talking about is replacing "const T defaultInstance;" with
// Execute the default constructor on the first new element
newSpace[i].constructor() ;
// Take a reference to this object for copying to subsequent instances
const T& defaultInstance = newSpace[i] ;
// Advance i to the next element
++i ;
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32618
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug libstdc++/32618] std::vector calls uneccessary constructors instead of inplace construction of first object
2007-07-04 0:46 [Bug libstdc++/32618] New: std::vector calls uneccessary constructors instead of inplace construction of first object oliver at kfs dot org
` (2 preceding siblings ...)
2007-07-04 4:27 ` oliver at kfs dot org
@ 2007-07-04 4:34 ` pinskia at gcc dot gnu dot org
2007-07-04 5:45 ` oliver at kfs dot org
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-07-04 4:34 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from pinskia at gcc dot gnu dot org 2007-07-04 04:34 -------
Well for one push_back takes "const T&". This is what I was talking about, you
can't really get any better in that case. Now the resize case is a different
story.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32618
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug libstdc++/32618] std::vector calls uneccessary constructors instead of inplace construction of first object
2007-07-04 0:46 [Bug libstdc++/32618] New: std::vector calls uneccessary constructors instead of inplace construction of first object oliver at kfs dot org
` (3 preceding siblings ...)
2007-07-04 4:34 ` pinskia at gcc dot gnu dot org
@ 2007-07-04 5:45 ` oliver at kfs dot org
2007-11-28 0:57 ` pcarlini at suse dot de
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: oliver at kfs dot org @ 2007-07-04 5:45 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from oliver at kfs dot org 2007-07-04 05:45 -------
Doh - yes - you're completely right about push_back. push_back itself isn't
incurring the temporary variable, Foo() is. Lost track of that investigating
the resize thing.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32618
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug libstdc++/32618] std::vector calls uneccessary constructors instead of inplace construction of first object
2007-07-04 0:46 [Bug libstdc++/32618] New: std::vector calls uneccessary constructors instead of inplace construction of first object oliver at kfs dot org
` (4 preceding siblings ...)
2007-07-04 5:45 ` oliver at kfs dot org
@ 2007-11-28 0:57 ` pcarlini at suse dot de
2008-01-02 20:37 ` pcarlini at suse dot de
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pcarlini at suse dot de @ 2007-11-28 0:57 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from pcarlini at suse dot de 2007-11-28 00:56 -------
Just a short note to follow up to my first message: as expected, in the next
standard both push_back and resize will be very different. The signature of the
new push_back, already available under the experimental C++0x mode, becomes:
template<typename... Args>
void
push_back(Args&&... args)
As regards resize, will be split into:
resize(size_type)
resize(size_type, const T&)
I'm considering implementing the new resize too under C++0x, in that case this
PR will be closed.
--
pcarlini at suse dot de changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |pcarlini at suse dot de
Status|WAITING |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2007-11-28 00:56:53
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32618
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug libstdc++/32618] std::vector calls uneccessary constructors instead of inplace construction of first object
2007-07-04 0:46 [Bug libstdc++/32618] New: std::vector calls uneccessary constructors instead of inplace construction of first object oliver at kfs dot org
` (5 preceding siblings ...)
2007-11-28 0:57 ` pcarlini at suse dot de
@ 2008-01-02 20:37 ` pcarlini at suse dot de
2009-12-02 0:01 ` paolo dot carlini at oracle dot com
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pcarlini at suse dot de @ 2008-01-02 20:37 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from pcarlini at suse dot de 2008-01-02 18:45 -------
Note that the split resize requires DefaultConstructible for the first
overload, and therefore, missing Concepts, the vector class cannot be
explicitely instantiated anymore for non-DefaultConstructible types.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32618
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug libstdc++/32618] std::vector calls uneccessary constructors instead of inplace construction of first object
2007-07-04 0:46 [Bug libstdc++/32618] New: std::vector calls uneccessary constructors instead of inplace construction of first object oliver at kfs dot org
` (6 preceding siblings ...)
2008-01-02 20:37 ` pcarlini at suse dot de
@ 2009-12-02 0:01 ` paolo dot carlini at oracle dot com
2010-01-08 15:42 ` paolo dot carlini at oracle dot com
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: paolo dot carlini at oracle dot com @ 2009-12-02 0:01 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from paolo dot carlini at oracle dot com 2009-12-02 00:01 -------
*** Bug 42242 has been marked as a duplicate of this bug. ***
--
paolo dot carlini at oracle dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |igodard at pacbell dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32618
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug libstdc++/32618] std::vector calls uneccessary constructors instead of inplace construction of first object
2007-07-04 0:46 [Bug libstdc++/32618] New: std::vector calls uneccessary constructors instead of inplace construction of first object oliver at kfs dot org
` (7 preceding siblings ...)
2009-12-02 0:01 ` paolo dot carlini at oracle dot com
@ 2010-01-08 15:42 ` paolo dot carlini at oracle dot com
2010-06-16 11:04 ` paolo dot carlini at oracle dot com
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: paolo dot carlini at oracle dot com @ 2010-01-08 15:42 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from paolo dot carlini at oracle dot com 2010-01-08 15:42 -------
Note: the same problem with the DefaultConstructible requirement affects for
example the new constructor vector(size_type). Thinking more about these issues
I'm wondering whether in N3000 std::vector & co are still supposed to be
explicitly instantiable for non-DefaultConstructible types - which would
require a quite boring dispatching and base-class dances for the whole class
for the sake of a few members, now that Concepts are gone - or not, or maybe
just as QoI. Does anybody have an idea? Maybe not, maybe is not supposed to,
otherwise, N2983 would not add the has_default_constructor trait as-if it was
not necessary before...
--
paolo dot carlini at oracle dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jwakely dot gcc at gmail dot
| |com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32618
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug libstdc++/32618] std::vector calls uneccessary constructors instead of inplace construction of first object
2007-07-04 0:46 [Bug libstdc++/32618] New: std::vector calls uneccessary constructors instead of inplace construction of first object oliver at kfs dot org
` (8 preceding siblings ...)
2010-01-08 15:42 ` paolo dot carlini at oracle dot com
@ 2010-06-16 11:04 ` paolo dot carlini at oracle dot com
2010-06-18 18:08 ` paolo at gcc dot gnu dot org
2010-06-18 18:22 ` paolo dot carlini at oracle dot com
11 siblings, 0 replies; 13+ messages in thread
From: paolo dot carlini at oracle dot com @ 2010-06-16 11:04 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from paolo dot carlini at oracle dot com 2010-06-16 11:04 -------
On it.
--
paolo dot carlini at oracle dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |paolo dot carlini at oracle
|dot org |dot com
Status|NEW |ASSIGNED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32618
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug libstdc++/32618] std::vector calls uneccessary constructors instead of inplace construction of first object
2007-07-04 0:46 [Bug libstdc++/32618] New: std::vector calls uneccessary constructors instead of inplace construction of first object oliver at kfs dot org
` (9 preceding siblings ...)
2010-06-16 11:04 ` paolo dot carlini at oracle dot com
@ 2010-06-18 18:08 ` paolo at gcc dot gnu dot org
2010-06-18 18:22 ` paolo dot carlini at oracle dot com
11 siblings, 0 replies; 13+ messages in thread
From: paolo at gcc dot gnu dot org @ 2010-06-18 18:08 UTC (permalink / raw)
To: gcc-bugs
------- Comment #11 from paolo at gcc dot gnu dot org 2010-06-18 18:08 -------
Subject: Bug 32618
Author: paolo
Date: Fri Jun 18 18:07:45 2010
New Revision: 161009
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=161009
Log:
2010-06-18 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/32618
* include/bits/stl_list.h (vector<>::_M_default_initialize,
_M_default_append): Declare.
(list<>::list(size_type), resize(size_type)): Add in C++0x mode,
use the latter.
* include/bits/list.tcc (list<>::resize, _M_default_append): Define.
* include/bits/stl_vector.h (vector<>::_M_default_initialize,
_M_default_append): Declare.
(vector<>::vector(size_type), resize(size_type)): Add in C++0x mode,
use the latter.
* include/bits/vector.tcc (vector<>::_M_default_append): Define.
* include/bits/stl_deque.h (deque<>::_M_default_initialize,
_M_default_append): Declare.
(deque<>::deque(size_type), resize(size_type)): Add in C++0x mode,
use the latter.
* include/bits/deque.tcc (deque<>::_M_default_append): Define.
* include/debug/vector: Update.
* include/debug/deque: Likewise.
* include/debug/list: Likewise.
* include/profile/vector: Likewise.
* include/profile/deque: Likewise.
* include/profile/list: Likewise.
* include/bits/forward_list.h (_M_default_initialize,
_M_default_insert_after): Declare.
(forward_list<>::forward_list(size_type), resize(size_type)): Fix,
use the latter.
* include/bits/forward_list.tcc (forward_list<>::_M_default_append,
_M_default_insert_after): Define.
* testsuite/util/testsuite_api.h (NonCopyConstructible): Add.
* testsuite/23_containers/forward_list/modifiers/6.cc: Move to...
* testsuite/23_containers/forward_list/capacity/resize_size.cc:
... here.
* testsuite/23_containers/forward_list/cons/10.cc: Move to...
* testsuite/23_containers/forward_list/cons/cons_size.cc: ... here.
* testsuite/23_containers/vector/resize/1.cc: Move to...
* testsuite/23_containers/vector/capacity/resize/1.cc: ... here.
* testsuite/23_containers/vector/resize/moveable.cc: Move to...
* testsuite/23_containers/vector/resize/capacity/moveable.cc: ... here.
* testsuite/23_containers/vector/cons/cons_size.cc: New.
* testsuite/23_containers/vector/capacity/resize/resize_size.cc:
Likewise.
* testsuite/23_containers/deque/cons/cons_size.cc: Likewise.
* testsuite/23_containers/deque/capacity/resize_size.cc: Likewise.
* testsuite/23_containers/list/cons/cons_size.cc: Likewise.
* testsuite/23_containers/list/capacity/resize_size.cc: Likewise.
* testsuite/23_containers/vector/capacity/resize/moveable.cc: Adjust.
* testsuite/23_containers/deque/capacity/moveable.cc: Likewise.
* testsuite/23_containers/forward_list/requirements/dr438/
assign_neg.cc: Adjust dg-error line numbers.
* testsuite/23_containers/forward_list/requirements/dr438/
insert_neg.cc: Likewise.
* testsuite/23_containers/forward_list/requirements/dr438/
constructor_1_neg.cc: Likewise.
* testsuite/23_containers/forward_list/requirements/dr438/
constructor_2_neg.cc: Likewise.
* testsuite/23_containers/vector/requirements/dr438/
assign_neg.cc: Likewise.
* testsuite/23_containers/vector/requirements/dr438/insert_neg.cc:
Likewise.
* testsuite/23_containers/vector/requirements/dr438/
constructor_1_neg.cc: Likewise.
* testsuite/23_containers/vector/requirements/dr438/
constructor_2_neg.cc: Likewise.
* testsuite/23_containers/deque/requirements/dr438/
assign_neg.cc: Likewise.
* testsuite/23_containers/deque/requirements/dr438/insert_neg.cc:
Likewise.
* testsuite/23_containers/deque/requirements/dr438/
constructor_1_neg.cc: Likewise.
* testsuite/23_containers/deque/requirements/dr438/
constructor_2_neg.cc: Likewise.
* testsuite/23_containers/list/requirements/dr438/assign_neg.cc:
Likewise.
* testsuite/23_containers/list/requirements/dr438/insert_neg.cc:
Likewise.
* testsuite/23_containers/list/requirements/dr438/
constructor_1_neg.cc: Likewise.
* testsuite/23_containers/list/requirements/dr438/
constructor_2_neg.cc: Likewise.
Added:
trunk/libstdc++-v3/testsuite/23_containers/deque/capacity/resize_size.cc
trunk/libstdc++-v3/testsuite/23_containers/deque/cons/cons_size.cc
trunk/libstdc++-v3/testsuite/23_containers/forward_list/capacity/resize_size.cc
- copied, changed from r160898,
trunk/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/6.cc
trunk/libstdc++-v3/testsuite/23_containers/forward_list/cons/cons_size.cc
- copied, changed from r160898,
trunk/libstdc++-v3/testsuite/23_containers/forward_list/cons/10.cc
trunk/libstdc++-v3/testsuite/23_containers/list/capacity/resize_size.cc
trunk/libstdc++-v3/testsuite/23_containers/list/cons/cons_size.cc
trunk/libstdc++-v3/testsuite/23_containers/vector/capacity/resize/
- copied from r160967,
trunk/libstdc++-v3/testsuite/23_containers/vector/resize/
trunk/libstdc++-v3/testsuite/23_containers/vector/capacity/resize/resize_size.cc
trunk/libstdc++-v3/testsuite/23_containers/vector/cons/cons_size.cc
Removed:
trunk/libstdc++-v3/testsuite/23_containers/forward_list/cons/10.cc
trunk/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/6.cc
trunk/libstdc++-v3/testsuite/23_containers/vector/resize/
Modified:
trunk/libstdc++-v3/ChangeLog
trunk/libstdc++-v3/include/bits/deque.tcc
trunk/libstdc++-v3/include/bits/forward_list.h
trunk/libstdc++-v3/include/bits/forward_list.tcc
trunk/libstdc++-v3/include/bits/list.tcc
trunk/libstdc++-v3/include/bits/stl_deque.h
trunk/libstdc++-v3/include/bits/stl_list.h
trunk/libstdc++-v3/include/bits/stl_vector.h
trunk/libstdc++-v3/include/bits/vector.tcc
trunk/libstdc++-v3/include/debug/deque
trunk/libstdc++-v3/include/debug/list
trunk/libstdc++-v3/include/debug/vector
trunk/libstdc++-v3/include/profile/deque
trunk/libstdc++-v3/include/profile/list
trunk/libstdc++-v3/include/profile/vector
trunk/libstdc++-v3/testsuite/23_containers/deque/capacity/moveable.cc
trunk/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/assign_neg.cc
trunk/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_1_neg.cc
trunk/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_2_neg.cc
trunk/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/insert_neg.cc
trunk/libstdc++-v3/testsuite/23_containers/forward_list/requirements/dr438/assign_neg.cc
trunk/libstdc++-v3/testsuite/23_containers/forward_list/requirements/dr438/constructor_1_neg.cc
trunk/libstdc++-v3/testsuite/23_containers/forward_list/requirements/dr438/constructor_2_neg.cc
trunk/libstdc++-v3/testsuite/23_containers/forward_list/requirements/dr438/insert_neg.cc
trunk/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc
trunk/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc
trunk/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc
trunk/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc
trunk/libstdc++-v3/testsuite/23_containers/vector/capacity/resize/moveable.cc
trunk/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/assign_neg.cc
trunk/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_1_neg.cc
trunk/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_2_neg.cc
trunk/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/insert_neg.cc
trunk/libstdc++-v3/testsuite/util/testsuite_api.h
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32618
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug libstdc++/32618] std::vector calls uneccessary constructors instead of inplace construction of first object
2007-07-04 0:46 [Bug libstdc++/32618] New: std::vector calls uneccessary constructors instead of inplace construction of first object oliver at kfs dot org
` (10 preceding siblings ...)
2010-06-18 18:08 ` paolo at gcc dot gnu dot org
@ 2010-06-18 18:22 ` paolo dot carlini at oracle dot com
11 siblings, 0 replies; 13+ messages in thread
From: paolo dot carlini at oracle dot com @ 2010-06-18 18:22 UTC (permalink / raw)
To: gcc-bugs
------- Comment #12 from paolo dot carlini at oracle dot com 2010-06-18 18:22 -------
Done.
--
paolo dot carlini at oracle dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|minor |normal
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.6.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32618
^ permalink raw reply [flat|nested] 13+ messages in thread