public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/46600] New: Default move constructor copies array elements instead of moving them.
@ 2010-11-22 12:32 yacwroy at gmail dot com
  2010-11-22 12:54 ` [Bug c++/46600] " redi at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: yacwroy at gmail dot com @ 2010-11-22 12:32 UTC (permalink / raw)
  To: gcc-bugs

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.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/46600] Default move constructor copies array elements instead of moving them.
  2010-11-22 12:32 [Bug c++/46600] New: Default move constructor copies array elements instead of moving them yacwroy at gmail dot com
@ 2010-11-22 12:54 ` redi at gcc dot gnu.org
  2010-11-22 23:42 ` yacwroy at gmail dot com
  2010-11-23  2:18 ` redi at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2010-11-22 12:54 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46600

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |DUPLICATE

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2010-11-22 12:54:04 UTC ---
dup of PR 46103 which was fixed last month 

if you want to test the latest development version you shouldn't use a build
from 6 months ago

*** This bug has been marked as a duplicate of bug 46103 ***


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/46600] Default move constructor copies array elements instead of moving them.
  2010-11-22 12:32 [Bug c++/46600] New: Default move constructor copies array elements instead of moving them yacwroy at gmail dot com
  2010-11-22 12:54 ` [Bug c++/46600] " redi at gcc dot gnu.org
@ 2010-11-22 23:42 ` yacwroy at gmail dot com
  2010-11-23  2:18 ` redi at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: yacwroy at gmail dot com @ 2010-11-22 23:42 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46600

--- Comment #2 from Simon Hill <yacwroy at gmail dot com> 2010-11-22 23:21:04 UTC ---
Sorry about that.
All that work and I didn't even notice my test GCC was the wrong one.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/46600] Default move constructor copies array elements instead of moving them.
  2010-11-22 12:32 [Bug c++/46600] New: Default move constructor copies array elements instead of moving them yacwroy at gmail dot com
  2010-11-22 12:54 ` [Bug c++/46600] " redi at gcc dot gnu.org
  2010-11-22 23:42 ` yacwroy at gmail dot com
@ 2010-11-23  2:18 ` redi at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2010-11-23  2:18 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46600

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> 2010-11-22 23:48:47 UTC ---
you should definitely try a recent snapshot, there's been a lot of work on move
support and g++ is pretty close to the n3126 definitions (although those aren't
set in stone yet and might change)


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-11-22 23:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-22 12:32 [Bug c++/46600] New: Default move constructor copies array elements instead of moving them yacwroy at gmail dot com
2010-11-22 12:54 ` [Bug c++/46600] " redi at gcc dot gnu.org
2010-11-22 23:42 ` yacwroy at gmail dot com
2010-11-23  2:18 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).