Disabling g++'s return-value optimisation

C++OptimizationCompiler ConstructionG++Return Value-Optimization

C++ Problem Overview


What flag(s) do I need on the command line to disable the return-value optimisation automatically enabled by the g++ compiler?

C++ Solutions


Solution 1 - C++

-fno-elide-constructors

> The C++ standard allows an implementation to omit creating a temporary which is only used to initialize another object of the same type. Specifying this option disables that optimization, and forces G++ to call the copy constructor in all cases. [Source: man gcc]


Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questioncpp_nonameView Question on Stackoverflow
Solution 1 - C++Prasoon SauravView Answer on Stackoverflow