Does Visual C++ not perform return-value optimization?
#include <cstdio>
struct Foo { ~Foo() { printf("Destructing...\n"); } };
Foo foo() { return Foo(); }
int main() { foo(); }
I compile and run it:
cl /O2 test.cpp
test.exe
And it prints:
Destructing...
Destructing...
Why is it not performing RVO?