[Bug c++/54509] New: If Move constructor is templatized then it is invoked else not

2012-09-06 Thread rsdevgun at gmail dot com
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: unassig...@gcc.gnu.org
ReportedBy: rsdev...@gmail.com


#include 
#include 

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
  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.


[Bug c++/54510] New: If Move constructor is templatized then, that version is invoked instead default move

2012-09-06 Thread rsdevgun at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54510

 Bug #: 54510
   Summary: If Move constructor is templatized then, that version
is invoked instead default move
Classification: Unclassified
   Product: gcc
   Version: 4.8.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: rsdev...@gmail.com


#include 
#include 

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
  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.