From the following code, If RVO has happened, I expect to see the 2 addresses pointing to the same location, however this is not the case (my compiler is MS VC9.0)
You seem to misunderstand RVO, try this example (actually NRVO):
std::string foo(const char* const s) { std::string out(s); std::cout << "address: " << (void*)(&out) << std::endl; return out; } int main() { std::string s = foo("abc"); std::cout << "address: " << (void*)(&s) << std::endl; }