Mirror of roytam1's UXP fork just in case Moonchild and Tobin decide to go after him
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

25 lines
696 B

// Implicit copy construct which is unused
class RC1 {
void AddRef();
void Release();
int mRefCnt;
};
// Explicit copy constructor which is used
class RC2 {
public:
RC2();
RC2(const RC2&);
private:
void AddRef();
void Release();
int mRefCnt;
};
void f() {
RC1* r1 = new RC1();
RC1* r1p = new RC1(*r1); // expected-error {{Invalid use of compiler-provided copy constructor on refcounted type}} expected-note {{The default copy constructor also copies the default mRefCnt property, leading to reference count imbalance issues. Please provide your own copy constructor which only copies the fields which need to be copied}}
RC2* r2 = new RC2();
RC2* r2p = new RC2(*r2);
}