[Bug c++/54509] New: If Move constructor is templatized then it is invoked else not
rsdevgun at gmail dot com
gcc-bugzilla@gcc.gnu.org
Thu Sep 6 20:10:00 GMT 2012
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54509
Bug #: 54509
Summary: If Move constructor is templatized then it is invoked
else not
Classification: Unclassified
Product: gcc
Version: 4.7.1
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: rsdevgun@gmail.com
#include <iostream>
#include <string>
using namespace std;
// uncomment to see the bug with 4.7.1 and 4.8.0
#define _BUG_
struct Test
{
Test() = default;
Test(const Test & )
{
cout << "ctor overload 1 & " << endl;
}
#ifdef _BUG_
template<typename T>
Test(T && )
{
//T* t = "0"; // For intentional error
cout << "ctor template version overload 2 && " << endl;
}
#else
Test(Test && )
{
cout << "ctor specialized overload 2 && " << endl;
}
#endif
};
int main()
{
Test t1( []()-> Test { return Test();}() );
return 0;
}
I expect Test(Test && ) to be invokved (without template version).
Also if you uncommment //T* t = "0"; -> you will see that data type is not a
magical data type, Being same as class itself, behavior is wrong.
More information about the Gcc-bugs
mailing list