How to disable return value optimization in Visual

2019-01-27 19:49发布

Is it possible to disable RVO (return value optimization) in Visual Studio 2010? Setting optimization flag to /Od (turns off all optimizations) doesn't help. In g++ there exists flag -fno-elide-constructors which disables RVO.

3条回答
闹够了就滚
2楼-- · 2019-01-27 19:56

There is never any reason to disable this optimisation! What are you trying to achieve? It helps debug builds run faster without any bad side-effects at all. It also ensures code dependent on RVO or NRVO works identically in debug and release.

查看更多
叼着烟拽天下
3楼-- · 2019-01-27 20:03

You cannot. It is just that simple. RVO/NRVO is Standard, and your code should not depend on it not being present.

查看更多
The star\"
4楼-- · 2019-01-27 20:13

Try to define your variable as volatile, maybe solves your problem. If it does not, you should send come code...

查看更多
登录 后发表回答