C++ optimization bug; incorrect assembly emitted - by Snaar

Status : 

  Fixed<br /><br />
		This item has been fixed in the current or upcoming version of this product.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 643764 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 2/13/2011 9:26:34 PM
Access Restriction Public


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.
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)