[Bug c++/12737] Class destructor never gets invoked even though its corresponding class constructor is invoked, and the object has gone out of scope. (Appears to be related to copy-constructor initialization with an argument that consists of an implicit user-defined cast operator that returns a CONST value.)
bangerth at dealii dot org
gcc-bugzilla@gcc.gnu.org
Thu Oct 23 00:17:00 GMT 2003
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12737
------- Additional Comments From bangerth at dealii dot org 2003-10-22 23:09 -------
Indeed. A reduced testcase is this:
----------------------------------------
#include <iostream>
struct Foo {
Foo() { std::cout << "foo constructor\n"; }
~Foo() { std::cout << "foo DESTRUCTOR\n"; }
Foo(const Foo & theFoo) { std::cout << "foo COPY-constructor\n"; }
};
struct Charlie {
Foo foo;
operator const Foo & () { return foo; }
};
static void bar ( Foo bar_foo ) {}
int main() {
Charlie charlie;
std::cout << "before call" << std::endl;
bar ( charlie );
std::cout << "after call" << std::endl;
}
---------------------------------------------
We fail to call the destructor on the temporary, but we do so with 3.3 and present
mainline. The bug is thus indeed fixed.
W.
More information about the Gcc-bugs
mailing list