Optimizer code gen bug in VC2012

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I have what appears to be a bug in compiler for a release build. The code runs fine in all compilers < 2012. I can see the error in the disassembly.<br/>
<br/>
<span style="color:#0000ff; font-size:small <span style="color:#0000ff; font-size:small <span style="color:#0000ff; font-size:small
<pre class="prettyprint while (nIndex != -1)
{
m_pBuddySet->insert(strBud.Mid(nStart, nIndex - nStart));
nStart = ++nIndex;
nIndex = strBud.Find(:, nIndex);
}[/code]
<span style="font-size:small <span style="font-size:small
<span class="x_t-marker <br/>

<pre class="prettyprint while (nIndex != -1)
0D40AD3D cmp ebx,0FFFFFFFFh
0D40AD40 je CLineProp::GetHoverBuddy+102h (0D40ADACh)
0D40AD42 jmp CLineProp::GetHoverBuddy+9Dh (0D40AD47h)
0D40AD44 mov ecx,dword ptr [ebp-10h]
{
m_pBuddySet->insert(strBud.Mid(nStart, nIndex - nStart));
0D40AD47 mov eax,ebx
0D40AD49 sub eax,ecx
0D40AD4B push eax
0D40AD4C push ecx
0D40AD4D lea eax,[ebp-2Ch]
0D40AD50 push eax
0D40AD51 mov ecx,edi
0D40AD53 call StringHash::CHashedString_t<CSuperString,StringHash::HashStringTraits<CSuperString> >::Mid (0D40E1FDh)
0D40AD58 and dword ptr [ebp-4],0
0D40AD5C push eax
0D40AD5D lea ecx,[ebp-14h]
0D40AD60 call CTag::CTag (0D236416h)
0D40AD65 lea eax,[ebp-14h]
0D40AD68 push eax
0D40AD69 lea eax,[ebp-1Ch]
0D40AD6C mov byte ptr [ebp-4],1
0D40AD70 mov ecx,dword ptr [esi]
0D40AD72 push eax
0D40AD73 call codeproject::sorted_vector<CTag,1,std::less<CTag>,std::allocator<CTag> >::insert (0D25D8AEh)
0D40AD78 lea ecx,[ebp-14h]
{
m_pBuddySet->insert(strBud.Mid(nStart, nIndex - nStart));
0D40AD7B mov byte ptr [ebp-4],0
0D40AD7F call StringHash::CHashedString_t<CSuperString,StringHash::HashStringTraits<CSuperString> >::Empty (0D222950h)
0D40AD84 or dword ptr [ebp-4],0FFFFFFFFh
0D40AD88 lea ecx,[ebp-2Ch]
0D40AD8B call CSuperString::~CSuperString (0D490000h)
nStart = ++nIndex;
0D40AD90 inc ebx
nIndex = strBud.Find(:, nIndex);
0D40AD91 push ebx
0D40AD92 push 3Ah
0D40AD94 mov ecx,edi
0D40AD96 call StringHash::CHashedString_t<CSuperString,StringHash::HashStringTraits<CSuperString> >::Get (0D222811h)
0D40AD9B mov ecx,eax
0D40AD9D call CSuperString::Find (0D48FBC0h)
0D40ADA2 mov ebx,eax
0D40ADA4 cmp ebx,0FFFFFFFFh
0D40ADA7 jne CLineProp::GetHoverBuddy+9Ah (0D40AD44h)
nStart = ++nIndex;
0D40ADA9 mov dword ptr [ebp-10h],ebx
}
[/code]
<br/>
<span class="x_t-marker The last line of the assembly is not supposed to be behind the while loop condition so it only executes it once at the end of the while.
<span style="font-size:small <span style="font-size:small <span style="font-size:small <span style="font-size:small
<span class="x_t-marker Heres what VC2010 generates:<br/>


<br/>

<pre class="prettyprint while (nIndex != -1)
112EBE54 cmp dword ptr [esp+10h],0FFFFFFFFh
112EBE59 je CLineProp::GetHoverBuddy+12Dh (112EBED4h)
{
m_pBuddySet->insert(strBud.Mid(nStart, nIndex - nStart));
112EBE5B mov eax,dword ptr [esp+10h]
112EBE5F sub eax,edi
112EBE61 push eax
112EBE62 push edi
112EBE63 lea eax,[esp+2Ch]
112EBE67 push eax
112EBE68 mov eax,dword ptr [esp+20h]
112EBE6C call StringHash::CHashedString_t<CSuperString,StringHash::HashStringTraits<CSuperString> >::Mid (112EF256h)
112EBE71 and dword ptr [esp+40h],0
112EBE76 lea ecx,[esp+18h]
112EBE7A push ecx
112EBE7B mov edi,eax
112EBE7D call CTag::CTag (11115C8Ah)
112EBE82 lea eax,[esp+18h]
112EBE86 push eax
112EBE87 lea eax,[esp+20h]
112EBE8B mov byte ptr [esp+44h],1
112EBE90 mov edi,dword ptr [ebx]
112EBE92 push eax
112EBE93 call codeproject::sorted_vector<CTag,1,std::less<CTag>,std::allocator<CTag> >::insert (1113C141h)
112EBE98 lea esi,[esp+18h]
112EBE9C mov byte ptr [esp+40h],0
112EBEA1 call StringHash::CHashedString_t<CSuperString,StringHash::HashStringTraits<CSuperString> >::Empty (11102560h)
112EBEA6 or dword ptr [esp+40h],0FFFFFFFFh
112EBEAB lea ecx,[esp+24h]
112EBEAF call CSuperString::~CSuperString (11370D10h)
nStart = ++nIndex;
112EBEB4 mov edi,dword ptr [esp+10h]
nIndex = strBud.Find(:, nIndex);
112EBEB8 mov eax,dword ptr [esp+14h]
112EBEBC push 3Ah
112EBEBE inc edi
112EBEBF call StringHash::CHashedString_t<CSuperString,StringHash::HashStringTraits<CSuperString> >::Get (11102441h)
112EBEC4 mov edx,edi
112EBEC6 call CSuperString::Find (11370930h)
112EBECB mov dword ptr [esp+10h],eax
112EBECF cmp eax,0FFFFFFFFh
112EBED2 jne CLineProp::GetHoverBuddy+0B4h (112EBE5Bh)
}
[/code]
<br/>
Please help or even better fix ASAP!

<span class="x_t-marker


<span class="x_t-marker






<span class="x_t-marker <span style="color:#1e1e1e; font-size:small <span style="color:#1e1e1e; font-size:small <span style="color:#1e1e1e; font-size:small
<span style="color:#1e1e1e; font-size:small <span style="color:#1e1e1e; font-size:small <span style="color:#1e1e1e; font-size:small



View the full article
 
Back
Top