[Bug c++/46600] New: Default move constructor copies array elements instead of moving them.
yacwroy at gmail dot com
gcc-bugzilla@gcc.gnu.org
Mon Nov 22 12:32:00 GMT 2010
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46600
Summary: Default move constructor copies array elements instead
of moving them.
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: yacwroy@gmail.com
Created attachment 22482
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22482
Complete example code. Compile with 4.6 or higher using -std=c++0x.
N3126: § 12.8.17 [move constructors]:
--(3): "an array is initialized by moving each element in the manner
appropriate to the element type"
If you have a class with a member array and you call the default move
constructor for said class, the move constructor COPIES said array elements.
From what the standard says, it seems it should MOVE these elements.
VERSION: 4.6.0 20100529 (experimental) (GCC)
4.5.1 is unable to explicitly default the move constructor.
I don't have any other functional versions between these two.
NOTE: I have added Pedro Lamarão's patch
http://gcc.gnu.org/ml/gcc-patches/2007-04/msg00620.html to my 4.6.0 but I can't
see this affecting anything.
TARGET: x86_64-unknown-linux-gnu
SYSTEM: Core2Duo / Ubuntu(64) 10.4.
ATTACHMENT:
Compiles OK with -std=c++0x.
OUTPUT:
copy
copy
move
PROBLEM:
According to the C++ spec (ver N3126), I think the first 2 "copy"s should be
"move"s.
More information about the Gcc-bugs
mailing list