Home Dashboard Directory Help
Search

C++ optimization bug; incorrect assembly emitted by Snaar


Status: 

Closed
 as Fixed Help for as Fixed


2
0
Sign in
to vote
Type: Bug
ID: 643764
Opened: 2/13/2011 9:26:34 PM
Access Restriction: Public
0
Workaround(s)
view
0
User(s) can reproduce this bug

Description

Attached is a single C++ source file with project file and solution file. Also attached is assembly output of one of the functions as viewed from internal IDE debugger of code compiled in release mode.

Issue seems to be caused by unmatched "sub esp,0Ch" in assembly: esp register being adjusted to make space for a temporary variable on stack but then the register is never adjusted back, causing "pop esi" to put incorrect value in esi register on return, causing "this" pointer of calling function to be corrupted.

This issue happens only in release mode. Some code generation settings make this issue go away so please refer to the attached project, thought default release mode settings should be affected as well.
Details
Sign in to post a comment.
Posted by Microsoft on 6/25/2011 at 3:38 AM
Thank you for reporting this issue. We have identified the root cause of the problem as a bug in the compiler backend. The bug is due to a bad interaction between dead code elimination and structures passed by value as function arguments and return values. The bug will be fixed in the next release of the compiler.

Windows C++ Compiler Team.
Posted by Microsoft on 2/14/2011 at 1:30 AM
Thanks for your feedback.
We are routing this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by Microsoft on 2/13/2011 at 9:59 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.
File Name Submitted By Submitted On File Size  
test01project.zip 2/13/2011 2 KB
test01_partial_asm.txt 2/13/2011 2 KB
test01.cpp 2/13/2011 797 bytes