int _tmain(int argc, _TCHAR* argv[])
{
string *pStr = new string ("abc");
delete pStr;
return 0;
}
VS2005,Release,优化关闭时的汇编代码
int _tmain(int argc, _TCHAR* argv[])
{
00401B40 push ebp
00401B41 mov ebp,esp
00401B43 push 0FFFFFFFFh
00401B45 push offset __ehhandler$?ThreadFunc1@@YGKPAX@Z+29h (401D99h)
00401B4A mov eax,dword ptr fs:[00000000h]
00401B50 push eax
00401B51 sub esp,1Ch
00401B54 mov eax,dword ptr [___security_cookie (403004h)]
00401B59 xor eax,ebp
00401B5B push eax
00401B5C lea eax,[ebp-0Ch]
00401B5F mov dword ptr fs:[00000000h],eax
string *pStr = new string ("abc");
00401B65 push 1Ch
00401B67 call operator new (40112Eh)
00401B6C add esp,4
00401B6F mov dword ptr [ebp-18h],eax
00401B72 mov dword ptr [ebp-4],0
00401B79 cmp dword ptr [ebp-18h],0
00401B7D je main+52h (401B92h)
00401B7F push 4025ACh
00401B84 mov ecx,dword ptr [ebp-18h]
00401B87 call dword ptr [__imp_std::basic_string ,std::allocator >::basic_string ,std::allocator > (402050h)]
00401B8D mov dword ptr [ebp-24h],eax
00401B90 jmp main+59h (401B99h)
00401B92 mov dword ptr [ebp-24h],0
00401B99 mov eax,dword ptr [ebp-24h]
00401B9C mov dword ptr [ebp-14h],eax
00401B9F mov dword ptr [ebp-4],0FFFFFFFFh
00401BA6 mov ecx,dword ptr [ebp-14h]
00401BA9 mov dword ptr [ebp-10h],ecx
delete pStr;
00401BAC mov edx,dword ptr [ebp-10h]
00401BAF mov dword ptr [ebp-20h],edx
00401BB2 mov eax,dword ptr [ebp-20h]
00401BB5 mov dword ptr [ebp-1Ch],eax
00401BB8 cmp dword ptr [ebp-1Ch],0
00401BBC je main+8Dh (401BCDh)
00401BBE push 1
00401BC0 mov ecx,dword ptr [ebp-1Ch]
00401BC3 call std::basic_string ,std::allocator >::`scalar deleting destructor' (4010E0h)
00401BC8 mov dword ptr [ebp-28h],eax
00401BCB jmp main+94h (401BD4h)
00401BCD mov dword ptr [ebp-28h],0
return 0;
00401BD4 xor eax,eax
}
00401BD6 mov ecx,dword ptr [ebp-0Ch]
00401BD
{
string *pStr = new string ("abc");
delete pStr;
return 0;
}
VS2005,Release,优化关闭时的汇编代码
int _tmain(int argc, _TCHAR* argv[])
{
00401B40 push ebp
00401B41 mov ebp,esp
00401B43 push 0FFFFFFFFh
00401B45 push offset __ehhandler$?ThreadFunc1@@YGKPAX@Z+29h (401D99h)
00401B4A mov eax,dword ptr fs:[00000000h]
00401B50 push eax
00401B51 sub esp,1Ch
00401B54 mov eax,dword ptr [___security_cookie (403004h)]
00401B59 xor eax,ebp
00401B5B push eax
00401B5C lea eax,[ebp-0Ch]
00401B5F mov dword ptr fs:[00000000h],eax
string *pStr = new string ("abc");
00401B65 push 1Ch
00401B67 call operator new (40112Eh)
00401B6C add esp,4
00401B6F mov dword ptr [ebp-18h],eax
00401B72 mov dword ptr [ebp-4],0
00401B79 cmp dword ptr [ebp-18h],0
00401B7D je main+52h (401B92h)
00401B7F push 4025ACh
00401B84 mov ecx,dword ptr [ebp-18h]
00401B87 call dword ptr [__imp_std::basic_string ,std::allocator >::basic_string ,std::allocator > (402050h)]
00401B8D mov dword ptr [ebp-24h],eax
00401B90 jmp main+59h (401B99h)
00401B92 mov dword ptr [ebp-24h],0
00401B99 mov eax,dword ptr [ebp-24h]
00401B9C mov dword ptr [ebp-14h],eax
00401B9F mov dword ptr [ebp-4],0FFFFFFFFh
00401BA6 mov ecx,dword ptr [ebp-14h]
00401BA9 mov dword ptr [ebp-10h],ecx
delete pStr;
00401BAC mov edx,dword ptr [ebp-10h]
00401BAF mov dword ptr [ebp-20h],edx
00401BB2 mov eax,dword ptr [ebp-20h]
00401BB5 mov dword ptr [ebp-1Ch],eax
00401BB8 cmp dword ptr [ebp-1Ch],0
00401BBC je main+8Dh (401BCDh)
00401BBE push 1
00401BC0 mov ecx,dword ptr [ebp-1Ch]
00401BC3 call std::basic_string ,std::allocator >::`scalar deleting destructor' (4010E0h)
00401BC8 mov dword ptr [ebp-28h],eax
00401BCB jmp main+94h (401BD4h)
00401BCD mov dword ptr [ebp-28h],0
return 0;
00401BD4 xor eax,eax
}
00401BD6 mov ecx,dword ptr [ebp-0Ch]
00401BD