This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
bug in 1.0.1 temporaries not destroyed.
- To: egcs-bugs at cygnus dot com
- Subject: bug in 1.0.1 temporaries not destroyed.
- From: Ulf Larsson <ulf at sm dot luth dot se>
- Date: Wed, 29 Apr 1998 15:45:08 +0200
g++ -v
Reading specs from
/usr/local/lib/gcc-lib/alphaev56-dec-osf4.0c/egcs-2.90.23/specs
gcc version egcs-2.90.23 980102 (egcs-1.0.1 release)
#include <iostream.h>
class A {
public:
A() {N++;}
A(A const &) { N++;}
~A() {N--;}
bool f() const { return true;}
static int N;
};
int
A::N = 0;
A a() {
return A();
}
bool foo() {
return a().f() && a().f() && a().f();
}
int
main() {
for(int i = 0; i<5 ; ++i) {
foo();
}
cout << A::N << endl;
return 0;
}
This program will print '5'
Only two of the three temporary objects of type A in foo() are
destroyed.
for each call.
Has this been fixed in later versions?
Ulf Larsson