Hi,
VisualGDB sets the optimization level to “none” for debug builds because this makes it easier to debug the project. Debugging optimized code could be very complicated as the compiler would often reuse common chunks of generated code (complicating stepping) or destroy the values of the variables once they are no longer needed (preventing you from evaluating most of them in the debugger).
If your project only works with some optimization levels, but not with others, it likely contains bugs triggered by a specific memory layout, or runs out of stack/heap space. Either way, we would advise investigating this as it might cause further trouble in production code.