How to disable return value optimization in Visual Studio 2010?

Is it possible to disable RVO (return value optimization) in Visual Studio 2010? Setting the optimization flag to /Od (disables all optimizations) does not help. In g ++, there is the -fno-elide-constructors flag that disables RVO.

+7
source share
3 answers

You can not. It is just that simple. RVO / NRVO is standard, and your code should not depend on the fact that it is not present.

+7
source

Try defining your variable as volatile , maybe it will solve your problem. If this is not the case, you must send the arrival code ...

+1
source

There was never a reason to disable this optimization! What are you trying to achieve? This helps debug builds faster, without any bad side effects. It also ensures that RVO or NRVO dependent code works the same way in debugging and release.

0
source

All Articles