就一句代码: pPos = strrchr(pPos++,'.'); debug 和release下的编译出代码不同,导致了错误,假设执行此函数前pPos指向字符串 ".rm"
debug 下代码及反汇编:
pPos = strrchr(pPos++,'.');
1001538A mov eax,dword ptr [pPos]
10015390 mov dword ptr [ebp-1DCh],eax
10015396 mov ecx,dword ptr [pPos]
1001539C add ecx,1
1001539F mov dword ptr [pPos],ecx
100153A5 push 2Eh
100153A7 mov edx,dword ptr [ebp-1DCh]
100153AD push edx
100153AE call strrchr (10047970h)
100153B3 add esp,8
100153B6 mov dword ptr [pPos],eax
Release 下代码及反汇编:
pPos = strrchr(pPos++,'.');
1000B943 mov eax,dword ptr [pPos]
1000B949 mov dword ptr [ebp-0E0h],eax
1000B94F push 2Eh
1000B951 mov ecx,dword ptr [ebp-0E0h]
1000B957 push ecx
1000B958 call strrchr (10022E60h)
1000B95D add esp,8
1000B960 mov dword ptr [pPos],eax
1000B966 mov edx,dword ptr [pPos]
1000B96C add edx,1
1000B96F mov dword ptr [pPos],edx
debug下的代码执行完后 pPos为"rm",release下为"m"
原因在于debug下先执行++ 操作,release后执行++操作,原因不明,查找中,如果哪位知道请说明下
测试代码:
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
char* pText = "c://test.rm";
char* pPointer = NULL;
pPointer = pText;
pPointer = strrchr(pPointer++,'.');
MessageBox(0,pPointer,NULL,0);
return (int)0;
}
编译器:VS.NET 2003