A Visual C++ 2010 Win32-based application may crash or other function failures may occur if the project is compiled by using _fastcall and by using an optimization compiler option

Applies to: Visual Studio 2010

Symptoms


Consider the following scenario:
  • You create a Microsoft Visual C++ 2010 Win32-based project.
  • You use the _fastcall keyword in some functions of the project. Or, you set the Calling Convention property for the project to _fastcall.
  • You enable one of the optimization compiler options in Microsoft Visual Studio 2010. For example, you enable the Maximize Speed (/O2) optimization compiler option.

    Note When an optimization compiler option is enabled, the Return Value Optimization (RVO) feature is enabled in Visual Studio 2010.
  • You compile the project, and then you run the application.
In this scenario, the application may crash, or other function failures may occur.

For example, the application crashes because of an access violation exception.

Cause


This issue occurs because incorrect code is generated when the application is compiled by using _fastcall if the RVO feature is enabled. The incorrect code overwrites memory randomly. Therefore, various function failures may occur.  

Resolution


Hotfix information

A supported hotfix is now available from Microsoft. However, it is intended to correct only the problem that is described in this article. Apply it only to systems that are experiencing this specific problem. This hotfix may receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next software update that contains this hotfix.

To resolve this problem immediately, contact Microsoft Customer Support Services to obtain the hotfix. For a complete list of Microsoft Customer Support Services telephone numbers and information about support costs, visit the following Microsoft Web site:Note In special cases, charges that are ordinarily incurred for support calls may be canceled if a Microsoft Support Professional determines that a specific update will resolve your problem. The usual support costs will apply to additional support questions and issues that do not qualify for the specific update in question.



Prerequisites

To apply this hotfix, you must have Microsoft Visual Studio 2010 installed. 

Restart requirement

You do not have to restart the computer after you install the hotfix.

Hotfix replacement information

This hotfix does not replace any other hotfix.

File Information

The English version of this hotfix has the file attributes (or later file attributes) that are listed in the following table. The dates and times for these files are listed in Coordinated Universal Time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time item in Control Panel.


For all supported versions of Visual Studio 2010
File nameFile versionFile sizeDateTimePlatform
C2.dll16.0.30319.3792,508,60825-Oct-201008:42x86
C2.dll16.0.30319.3792,588,99225-Oct-201008:42x86
C2.dll16.0.30319.3792,629,44025-Oct-201008:42x86
C2.dll16.0.30319.3792,975,55225-Oct-201008:42x64
C2.dll16.0.30319.3797,351,61625-Oct-201008:42IA-64

Status


Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.