Possible copy constructor bug

  • Thread starter Thread starter Ioannis Vranos
  • Start date Start date
I

Ioannis Vranos

Unless I missing something, I think this is a bug.


ref class A
{
};


ref class B
{
public:
B(A) { }
B() {}
};


int main()
{
A a;

B b(a);
}


C:\c>cl /clr:safe temp.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 14.00.41013
for Microsoft (R) .NET Framework version 2.00.41013.0
Copyright (C) Microsoft Corporation. All rights reserved.

temp.cpp
temp.cpp(18) : error C2664: 'B::B(A)' : cannot convert parameter 1 from
'A' to '
A'
Cannot copy construct class 'A' due to ambiguous copy
constructors or no
available copy constructor

C:\c>



Am I making some mistake?
 
Try the following code, not the missing % from your example.
using namespace System;
ref class A
{
};


ref class B
{
public:
B(A%) { }
B() {}
};


int main()
{
A a;
B b(a);
}

Thanks,
Kapil
 
Puchi said:
Try the following code, not the missing % from your example.

using namespace System;
ref class A
{
};


ref class B
{
public:
B(A%) { }
B() {}
};


int main()
{
A a;
B b(a);
}


I know that % was missing, however % is not mandatory.
 
Ioannis said:
ref class A
{
};


ref class B
{
public:
B(A) { }
B() {}
};


int main()
{
A a;

B b(a);
}


C:\c>cl /clr:safe temp.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 14.00.41013
for Microsoft (R) .NET Framework version 2.00.41013.0
Copyright (C) Microsoft Corporation. All rights reserved.

temp.cpp
temp.cpp(18) : error C2664: 'B::B(A)' : cannot convert parameter 1 from
'A' to '
A'
Cannot copy construct class 'A' due to ambiguous copy
constructors or no
available copy constructor

C:\c>


I reported it as a bug under the title:


"Copy constructor bug".
 
Back
Top