Search

MSVC10 using copy constructor instead of move by Mooing Duck

Closed
as Deferred Help for as Deferred

1
0
Sign in
to vote
Type: Bug
ID: 778513
Opened: 2/4/2013 9:29:37 PM
Access Restriction: Public
1
Workaround(s)
0
User(s) can reproduce this bug
When compiling the code below, the output should obviously be "move", but instead, I see "copy". The compiler should be implicitly defining a move constructor for the track class that uses the move constructor of the root member, but seems to be using a defaulted copy constructor instead. Adding explicit move and copy constructors to the track class results in the expected behavior. (Discovered in MSVC10 express, confirmed in VS11 with November CRT)
Details (expand)

Visual Studio/Team Foundation Server/.NET Framework Tooling Version

Visual Studio 2012

Steps to reproduce

#include <iostream>

class track {
    struct root_type {
        root_type() {}
        root_type(const root_type& rhs) {std::cout << "copy";}
        root_type(root_type&& rhs) {std::cout << "move";}
    } root;
};

int main() {
    track mov_trak_0;
    track mov_trak_3(std::move(mov_trak_0));
    return 0;
}

Product Language

English

Operating System

Windows XP

Operating System Language

English

Actual results

copy

Expected results

move
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 2/5/2013 at 1:22 AM
Thank you for submitting feedback on Visual Studio and .NET Framework. Your issue has been routed to the appropriate VS development team for investigation. We will contact you if we require any additional information.
Posted by Microsoft on 2/4/2013 at 9:50 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.
Posted by Mooing Duck on 3/11/2013 at 9:04 PM
add explicit copy/move constructors