我在VC中用Debug模式查看下面两个函数的汇编代码,汇编代码是一样的。
int F(int *pInt)
{
   return *pInt;
}
int G(int &pInt)
{
   return pInt;
}
汇编代码如下:
17:   int F(int *pInt)
18:   {
00401800   push        ebp
00401801   mov         ebp,esp
00401803   sub         esp,40h
00401806   push        ebx
00401807   push        esi
00401808   push        edi
00401809   lea         edi,[ebp-40h]
0040180C   mov         ecx,10h
00401811   mov         eax,0CCCCCCCCh
00401816   rep stos    dword ptr [edi]
19:
20:       return *pInt;
00401818   mov         eax,dword ptr [ebp+8]
0040181B   mov         eax,dword ptr [eax]
21:   }
23:   int G(int &pInt)
24:   {
00401860   push        ebp
00401861   mov         ebp,esp
00401863   sub         esp,40h
00401866   push        ebx
00401867   push        esi
00401868   push        edi
00401869   lea         edi,[ebp-40h]
0040186C   mov         ecx,10h
00401871   mov         eax,0CCCCCCCCh
00401876   rep stos    dword ptr [edi]
25:       return pInt;
00401878   mov         eax,dword ptr [ebp+8]
0040187B   mov         eax,dword ptr [eax]
26:   }