fork download
#include <stdio.h>
class A
{
public:
	A() { printf("ctor %X\n", this); }
	A(const A& v) { printf("copy %X=%X\n", this, &v); *this=v; }
	int v, v2;
};

A fn(A v) { printf("fn %X\n", &v); v.v=9; return v; }
A fn2(A v) { printf("fn2 %X\n", &v); return fn(v); }
int main(){
	printf("Test 1\n");
	A a;
	A b = fn(a);
	printf("addr=%X\n", &b);
	printf("Test 2\n");
	A c = fn(A());
	printf("addr=%X\n", &c);
	printf("Test 3\n");
	A d = fn2(A());
	printf("addr=%X\n", &d);
}
Success #stdin #stdout 0s 2828KB
stdin
Standard input is empty
stdout
Test 1
ctor BFA3BD28
copy BFA3BD18=BFA3BD28
fn BFA3BD18
copy BFA3BD20=BFA3BD18
addr=BFA3BD20
Test 2
ctor BFA3BD08
fn BFA3BD08
copy BFA3BD10=BFA3BD08
addr=BFA3BD10
Test 3
ctor BFA3BCF8
fn2 BFA3BCF8
copy BFA3BCC8=BFA3BCF8
fn BFA3BCC8
copy BFA3BD00=BFA3BCC8
addr=BFA3BD00