#include <iostream>

using namespace std;

class A
{
    public:
	A(int a = 5)
	{
	    cout<<"A constructor "<<this<<endl;
	}
	~A()
	{
	    cout<<"A destructor "<<this<<endl;
	}
	A(const A & r)
	{
	    cout<<this<<" copy from "<<&r<<endl;
	}

    private:
	int a;
};

A fun(A param)
{
    A ret = param;
    return ret;
}

int main(int argc,char**argv)
{
    cout<<"\nfun(1),cout<<\"out\":\n";
    fun(1),cout<<"out"<<endl;

    cout<<"\n\nA a = fun(1):\n";
    A a = fun(1);
    return 0;
}

以g++ XX.cpp -fno-elide-constructors 运行,解除优化。