Max Speed Optimization /O2 Generates Incorrect Result - by Meng-Yuan Huang

Status : 


Sign in
to vote
ID 776967 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 1/19/2013 7:05:50 AM
Access Restriction Public


The compiler switch "Max Speed Optimization /O2" is default turned on in Release configuration.
My program generates incorrect result if this switch is used.

Sign in to post a comment.
Posted by Meng-Yuan Huang on 2/4/2013 at 5:29 PM
Hi Eric,


Meng-Yuan Huang
Posted by Eric [MSFT] on 2/4/2013 at 12:12 PM
Hi, thanks for the latest update. I can reproduce the problem now -- this is a bug in the compiler optimizer that we will fix in a future release.

If you need a source code workaround, you can turn off optimizations around MergeSort() with:

#pragma optimize("", off)
void MergeSort(...)
#pragma optimize("", on)

or separate out MergeSort into its own .cpp file and configure the project to compile just that file with /Od.

I'm going to close this MSConnect item. Feel free to reply if you have any more questions.

Posted by Meng-Yuan Huang on 2/3/2013 at 5:31 AM
Hi Eric,

Sorry, the test program really needn't mat.h.
Today, I have upload a new version, which fixed this problem.
Please try it.

Thank you.

Meng-Yuan Huang
Posted by Eric [MSFT] on 2/1/2013 at 2:16 PM
Hi, thanks for adding the new test. I am still not able to build the project. I am missing mat.h, and my team does not have a license to download Matlab.

In order to debug this, I need a project that does not depend on Matlab. Can you please provide that?

Posted by Meng-Yuan Huang on 1/25/2013 at 9:03 PM
Hi, I have solved the cmake issues. Please try

Meng-Yuan Huang
Posted by Eric [MSFT] on 1/22/2013 at 3:18 PM
Hello, thanks for the report. I'm not able to build the project. I get cmd.exe errors trying to build -- they are likely cmake issues that do not appear related to the issue at hand.

Can you please provide a simple one-project solution that exhibits the same error without any extra dependencies? From your code, it looks like you should be able to extract the necessary components.

Eric Brumer
Microsoft Visual C++
Posted by Microsoft on 1/20/2013 at 9:33 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 Microsoft on 1/19/2013 at 7:51 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(