Search

Bad instruction re-ordering causes crash in code generated by MSVC 2010 by chapmania

Closed
as Fixed Help for as Fixed

2
0
Sign in
to vote
Type: Bug
ID: 690294
Opened: 9/22/2011 3:22:00 PM
Access Restriction: Public
Moderator Decision: Sent to Engineering Team for consideration
0
Workaround(s)
1
User(s) can reproduce this bug
I have a short program that I believe causes MSVC 2010 to generate bad optimizations, leading to a crash at runtime.
It's valid C++ as far as I can tell. The debug build of this program runs fine.
Looking at the disassembly of the 'release' compile, it appears that some instruction re-ordering is a little over-zealous and causes the dereference of an invalid pointer.

I am using MSVC Express 2010, version "10.0.30319.1 RTMRel"
Details (expand)

Visual Studio/Team Foundation Server/.NET Framework Tooling version

Visual Studio 2010

Steps to reproduce

Compile the code in the pastebin at: http://ideone.com/5l68P using the default "release" configuration for MSVC 2010, and run it.
I will also attach this file after submitting the report.

Product Language

English

Operating System

Windows Vista

Operating System Language

English

Actual results

Access violation at runtime.

Expected results

Code should run successfully and return 0.
File Attachments
File Name Submitted By Submitted On File Size  
crash.cpp 9/22/2011 799 bytes
Sign in to post a comment.
Posted by Microsoft on 10/31/2011 at 11:34 AM
Hi,

Thanks again for reporting this issue. It will be fixed in the next release of Visual Studio.

Shayne Hiet-Block
VC++ Code Generation and Optimization Team
Posted by Dmitry Me on 9/25/2011 at 11:42 PM
I also reproduce this in 2k10 SP1. Indeed machine code emitted first does the memory access, then the comparison.
Posted by MS-Moderator07 [Feedback Moderator] on 9/22/2011 at 10:58 PM
Thanks for your feedback.

We are rerouting 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 MS-Moderator01 on 9/22/2011 at 3:44 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.