If expression of type 'const C' (not const reference) is passed to function accepting 'C' by value, gcc 3.2.0-3.2.2 doesn't call destructor for temporary argument object. ---- The code destr.cpp: #include <iostream> struct C { C(void) { std::cerr << this << "->C()\n"; } C(const C& c) { std::cerr << this << "->C(" << &c << ")\n"; } ~C(void) { std::cerr << this << "->~C()\n"; } }; struct C2 { const C get(void) const { return c; } void go(C c) {} C c; }; int main() { C2 c2; c2.go(c2.get()); } ---- Command line: # g++ -O0 -o destr destr.cpp ---- Output: ~/tmp# ./destr 0xbffff604->C() 0xbffff5f4->C(0xbffff604) 0xbffff604->~C() ~/tmp# Release: gcc-3.2.2 Environment: Linux linus 2.4.17-aa #6 SMP Thu Jan 3 17:53:55 EST 2002 i686 unknown How-To-Repeat: Returned object value should be const. Argument should be object by value. Compilation should be without optimization. With optimization turned on all destructors are called correctly.
State-Changed-From-To: open->analyzed State-Changed-Why: Confirmed, a regression in 3.2 w.r.t 3.0. It is fixed in 3.3 and mainline, though. W.
State-Changed-From-To: analyzed->closed State-Changed-Why: Fixed for the next release (3.3).