I have a fairly complex algorithm I’m building using both visual c 2008 and visual c 2010. The algorithm is producing bad output when I compile with optimization enabled in VC 2010 (specifically, /Og).
Building the same exact code in VC 2008 (with or without optimization) or in VC2010 without optimization produces an algorithm that behaves correctly.
I’m having a very hard time debugging the code with optimization enabled, and have been stuck on this for quite a while. Does anyone know any differences in optimization across versions?
It could be a compiler bug, but you should try /Wall to enable all the warnings and fix all of them. There are also runtime checks like /RTCu (Uninitialized local usage checks) which you can use to isolate the problem. Also inspect all the type castings in your code to make sure they are legit.