* [Bug libstdc++/52745] GCC4.7 vector uses copy instead of move constructor
2012-03-27 23:06 [Bug libstdc++/52745] New: GCC4.7 vector uses copy instead of move constructor J.W.Rogers+gcc at gmail dot com
@ 2012-03-27 23:13 ` paolo.carlini at oracle dot com
2012-03-27 23:20 ` J.W.Rogers+gcc at gmail dot com
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-03-27 23:13 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52745
--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-03-27 23:06:17 UTC ---
But Stuff' move-constructor isn't known not to throw...
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libstdc++/52745] GCC4.7 vector uses copy instead of move constructor
2012-03-27 23:06 [Bug libstdc++/52745] New: GCC4.7 vector uses copy instead of move constructor J.W.Rogers+gcc at gmail dot com
2012-03-27 23:13 ` [Bug libstdc++/52745] " paolo.carlini at oracle dot com
@ 2012-03-27 23:20 ` J.W.Rogers+gcc at gmail dot com
2012-03-27 23:26 ` paolo.carlini at oracle dot com
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: J.W.Rogers+gcc at gmail dot com @ 2012-03-27 23:20 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52745
--- Comment #2 from Jonathan Rogers <J.W.Rogers+gcc at gmail dot com> 2012-03-27 23:13:29 UTC ---
(In reply to comment #1)
> But Stuff' move-constructor isn't known not to throw...
Okay, so it is a new requirement for move constructors to be marked as nothrow
in order for vector to use them for relocation?
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libstdc++/52745] GCC4.7 vector uses copy instead of move constructor
2012-03-27 23:06 [Bug libstdc++/52745] New: GCC4.7 vector uses copy instead of move constructor J.W.Rogers+gcc at gmail dot com
2012-03-27 23:13 ` [Bug libstdc++/52745] " paolo.carlini at oracle dot com
2012-03-27 23:20 ` J.W.Rogers+gcc at gmail dot com
@ 2012-03-27 23:26 ` paolo.carlini at oracle dot com
2012-03-27 23:30 ` J.W.Rogers+gcc at gmail dot com
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-03-27 23:26 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52745
--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-03-27 23:21:59 UTC ---
Otherwise, if the move constructor by chance throws, the push_back cannot have
no effects, as required by 23.2.1/10. Actually the requirement holds for all
the containers, but only std::vector implements it in 4.7, the other containers
(I *think* only std::deque needs work) will follow.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libstdc++/52745] GCC4.7 vector uses copy instead of move constructor
2012-03-27 23:06 [Bug libstdc++/52745] New: GCC4.7 vector uses copy instead of move constructor J.W.Rogers+gcc at gmail dot com
` (2 preceding siblings ...)
2012-03-27 23:26 ` paolo.carlini at oracle dot com
@ 2012-03-27 23:30 ` J.W.Rogers+gcc at gmail dot com
2012-03-27 23:42 ` paolo.carlini at oracle dot com
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: J.W.Rogers+gcc at gmail dot com @ 2012-03-27 23:30 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52745
--- Comment #4 from Jonathan Rogers <J.W.Rogers+gcc at gmail dot com> 2012-03-27 23:25:45 UTC ---
(In reply to comment #3)
> Otherwise, if the move constructor by chance throws, the push_back cannot have
> no effects, as required by 23.2.1/10. Actually the requirement holds for all
> the containers, but only std::vector implements it in 4.7, the other containers
> (I *think* only std::deque needs work) will follow.
In my example code, if you comment out the copy constructor (leaving only the
move constructor) then vector will use the (potentially throwing) move
constructor.
If what you say is the case, shouldn't vector refuse to use the move
constructor?
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libstdc++/52745] GCC4.7 vector uses copy instead of move constructor
2012-03-27 23:06 [Bug libstdc++/52745] New: GCC4.7 vector uses copy instead of move constructor J.W.Rogers+gcc at gmail dot com
` (3 preceding siblings ...)
2012-03-27 23:30 ` J.W.Rogers+gcc at gmail dot com
@ 2012-03-27 23:42 ` paolo.carlini at oracle dot com
2012-03-28 0:12 ` paolo.carlini at oracle dot com
2012-03-28 0:22 ` J.W.Rogers+gcc at gmail dot com
6 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-03-27 23:42 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52745
--- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-03-27 23:30:23 UTC ---
That's known, it's a design choice: in that case you are essentially back to
the unsafe 4.6 behavior. Look for 'move_if_noexcept'.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libstdc++/52745] GCC4.7 vector uses copy instead of move constructor
2012-03-27 23:06 [Bug libstdc++/52745] New: GCC4.7 vector uses copy instead of move constructor J.W.Rogers+gcc at gmail dot com
` (4 preceding siblings ...)
2012-03-27 23:42 ` paolo.carlini at oracle dot com
@ 2012-03-28 0:12 ` paolo.carlini at oracle dot com
2012-03-28 0:22 ` J.W.Rogers+gcc at gmail dot com
6 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-03-28 0:12 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52745
--- Comment #6 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-03-27 23:44:44 UTC ---
Essentially the leeway for the unsafe fallback in the case of Comment #4 is
provided by 23.3.6.5/1: "If an exception is thrown by the move constructor of a
non-CopyInsertable T, the effects are unspecified".
But really, historically, people simply decided to replace for reallocations
unconditional moves with move_if_noexcexpt.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libstdc++/52745] GCC4.7 vector uses copy instead of move constructor
2012-03-27 23:06 [Bug libstdc++/52745] New: GCC4.7 vector uses copy instead of move constructor J.W.Rogers+gcc at gmail dot com
` (5 preceding siblings ...)
2012-03-28 0:12 ` paolo.carlini at oracle dot com
@ 2012-03-28 0:22 ` J.W.Rogers+gcc at gmail dot com
6 siblings, 0 replies; 8+ messages in thread
From: J.W.Rogers+gcc at gmail dot com @ 2012-03-28 0:22 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52745
Jonathan Rogers <J.W.Rogers+gcc at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
--- Comment #7 from Jonathan Rogers <J.W.Rogers+gcc at gmail dot com> 2012-03-28 00:11:41 UTC ---
Thanks Paolo. I understand the situation now.
Thanks for your time and sorry the erroneous report!
^ permalink raw reply [flat|nested] 8+ messages in thread