C++复制构造函数的疑问

书上说调用复制构造函数有三种情况,但在测试第三种时(如果函数的返回值是类的对象,函数执行完成返回调用者时)发现没有调用复制构造函数,代码如下:
#include
using namespace std;

class Point
{
public:
Point(int x=0,int y=0):x(x),y(y){}
Point(const Point &p)
{
cout << "call copy constructor" << endl;
x = p.x;
y = p.y;
}
int getX() const
{
return x;
}
int getY() const
{
return y;
}
private:
int x;
int y;
};

Point fun()
{
Point a(1,2);
return a;
}

int main(void)
{
Point a = fun();
cout << a.getX() << endl;

return 0;

}

理论上调用,但是有的编译器会对这个进行优化

Point fun()
{
Point a(1,2);
return a;
}

Point a = fun();

编译器会这样翻译

void fun(Point  &retObj)
{
Point a(1,2);
retObj = a;
}

将调用的返回对象,从栈传入,然后在函数内部调用拷贝构造函数,然后返回的赋值就不调用了。