using VS 2010 with full optimization / Ox, see the following two function calls:
static string test1(const string& input) { return input; } static void test2(const string& input, string& output) { output = input; }
If I use the latest test2, then the function is always optimized and the code is nested. However, test1 is not built in unless I turn off the exceptions. Does anyone know why this is?
Also, I expected the compiler to be able to perform as an efficient job in test1 like test2 if it uses return value optimization, but it doesn't seem to do that. It also puzzles me.
The reason I want to use the first signature of the function is because I have two compiled versions of the function. I want the calling code to always call test1, and when a particular compilation flag is set, I want it to add input to the copy and return it when the compilation flag is not set. I want it to be as close to -op as possible.
source share