Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable return value optimization in Visual Studio 2010?

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.

like image 745
Goran Avatar asked Mar 30 '12 10:03

Goran


2 Answers

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

like image 137
Puppy Avatar answered Oct 15 '22 11:10

Puppy


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

like image 35
Malkocoglu Avatar answered Oct 15 '22 12:10

Malkocoglu