c++.beta - return value optimization
- Christof Meerwald (43/43) Aug 22 2003 Hi,
Hi, #include <stdio.h> struct B { B() { printf("B::B() %08x\n", this); } ~B() { printf("B::~B() %08x\n", this); } }; struct C { C(const B &b) { } }; B f() { B b; return b; } int main() { C c1 = f(); // B::~B should be called here (just after C::C(const B &)) C c2 = f(); // B::~B should be called here (just after C::C(const B &)) printf("done\n"); return 0; } // but the output with 8.35.8n is: // B::B() 0012ff7d // B::B() 0012ff7f // done // B::~B() 0012ff7f // B::~B() 0012ff7d See 12.8 Copying class objects [class.copy], paragraph 15. bye, Christof -- http://cmeerw.org JID: cmeerw jabber.at mailto cmeerw at web.de
Aug 22 2003