Home Dashboard Directory Help
Search

Optimization flag -O2 issue in C/C++ compiler by kostik450


Status: 

Closed
 as Fixed Help for as Fixed


19
0
Sign in
to vote
Type: Bug
ID: 698296
Opened: 11/1/2011 2:48:03 AM
Access Restriction: Public
Moderator Decision: Sent to Engineering Team for consideration
0
Workaround(s)
view
8
User(s) can reproduce this bug

Description

Hello,

The following code prints "Error! 00 01 02 02" if we compile it with -O2 flag in Visual Studio 2010 SP1 C/C++ compiler for x86 and/or x64 platform.
If we compile it without this flag we have not a message "Error!" and we have "00 01 02 03".
I think this is a bug in the optimizations block of the compiler.

Thank you,
Constanthine
Details
Sign in to post a comment.
Posted by Microsoft on 1/13/2012 at 10:12 AM
The next version of Visual Studio has a preview version available. (http://msdn.microsoft.com/en-us/windows/apps/br229516). The Beta build is in the works.

If you'd like a hotfix for this issue for an earlier version of Visual Studio you can request one through customer support.

ian Bearman
VC++ Code Generation and Optimization Team
Posted by BuildMeister on 1/13/2012 at 4:58 AM

Hi Ian, If this bug is fixed, how do I get a hold of the fix. Btw the bug I was referring to is 713786.
Thanks,
Brent
Posted by Microsoft on 12/6/2011 at 11:34 AM
...between VS2005 and VS2010.
My hands really don't like typing VS2010 :)


ian Bearman
VC++ Code Generation and Optimization Team
Posted by Microsoft on 12/6/2011 at 11:33 AM
Sorry, i meant between VS2005 and VS2008.

ian Bearman
VC++ Code Generation and Optimization Team

Posted by Microsoft on 12/6/2011 at 11:33 AM
BuildMeister, i don't know of any regressions between VS2005 and VS2008 in this area. If you can can provide a standalone repro case for this i will gladly take a look.
This KB article has some data on how to create a repro: http://support.microsoft.com/kb/974229

The best repro is one that i can run and see the bug, but if that's not possible, a source file that produces the bad code when compiled is probably sufficient.

ian Bearman
VC++ Code Generation and Optimization Team
Posted by BuildMeister on 12/6/2011 at 11:18 AM
I have a similar problem with with VS 2010 -O2 flag. I have a large project that when compiled with -O2 does not compare an enum to a BYTE properly. Assuming that value returned by GetModuleVersion is 105 the code below will skip the required tasks for versions less than V106 & V107 when compiled with -O2, -O1 but execute normally when optimization is diabled. This code was previously compiled with vs 2005 and there no problems with the optimization flags. Are there any HOTFIX's that might address this problem.

enum CLASS_VERSION    // enumeration of versions (max is 255)
{
    V1=1,
    V2=2,
    V3=3,
    V100=100,
    V101=101,
    V102=102,
    V103=103,
    V104=104,
    V105=105,
    V106,    
    V107    
};
const int CUR_CLASS_VERSION=V107;


/*******************************************************************************
PURPOSE: Translates old versions data appropriately.
*******************************************************************************/
void LPersistAnalysisData::TranslateOldVersions(
    LTag<>& ModuleTag)            //target tag to translate from
{
    // translate something
        if (LOBYTE(ModuleTag.GetModuleVersion()) < V106)
    {
        // do something
    }

    // translate something
        if (LOBYTE(ModuleTag.GetModuleVersion()) < V107)
    {
        // do something
    }
}
Posted by Microsoft on 11/2/2011 at 11:17 AM
Thanks for reporting this issue. I can confirm this problem with VS2010 SP1. It will be fixed in the next major release of Visual Studio.

ian Bearman
VC++ Code Generation and Optimization Team
Posted by MS-Moderator10 [Feedback Moderator] on 11/1/2011 at 7:10 PM
Thank you for submitting feedback on Visual Studio 2010 and .NET Framework. Your issue has been routed to the appropriate VS development team for investigation. We will contact you if we require any additional information.
Posted by MS-Moderator01 on 11/1/2011 at 3:23 AM
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.