c++ - Visual Studio 2013 does not delete the copy constructor when a user-defined move constructor is provided -


i appreciate c++11 standard dictates:

if class definition not explicitly declare copy constructor, 1 declared implicitly. if class definition declares move constructor or move assignment operator, implicitly declared copy constructor defined deleted; otherwise, defined defaulted.

(actually copied here)

the following code:

#include <iostream>  struct c {     int x = 1;      c()     {     }      c(c&&)     {     } };  int main() {     const c c;     c c2(c);      std::cout << c.x << " " << c2.x << std::endl;      return 0; } 

does not compile on gcc 4.9.0, compiles fine on visual studio 2013 (compiler version 18.00.21005.1 x86). yet visual studio violation of standard, or doing wrong time? if violation of standard, there tracking bug or source behaviour documented?

you're not doing wrong, , interpretation of standard correct. visual c++ 2013 indeed not implement these rules properly.

a relevant bug report here:

default copy constructor generated when custom move constructor defined [c++11]

it's marked won't fix , comment development team is:

visual studio 2013 indeed not implement c++11 rules governing special member functions , move operations. include fix bug in next major release of visual studio.

the news things seem working in visual c++ 2015 rc. i've verified code triggers both compiler , intellisense errors. compiler diagnostic is:

error c2280: 'c::c(const c &)': attempting reference deleted function 

(from i've tested during past few months, msvc14 shaping pretty c++ compiler - lots of standard compliance issues have been fixed.)


Comments