This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]