This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
call of extra destructor
- To: egcs-bugs at egcs dot cygnus dot com
- Subject: call of extra destructor
- From: Alexander Zvyagin <zvyagin at mx dot ihep dot su>
- Date: Wed, 17 Mar 1999 19:52:55 GMT+03:00
Date: Wed, 17 Mar 1999 19:52:51 +0000
From: ZVYAGIN <ZVYAGIN@mx.ihep.su>
X-Sender: ZVYAGIN@polar.ihep.su
To: egcs-bugs@egcs.cygnus.com
Subject: call of extra destructor
Message-ID: <Pine.VMS.3.91-b11-vms.990317193653.20312A-100000@polar.ihep.su>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
// File
#include <stream.h>
class A
{
public:
~A (void) {cout << "D";}
A (void) {cout << "C";}
};
void f(A a) {}
int main(void)
{
{ A a; f(a); }
cout << endl;
return 0;
}
// End of file
$ g++ -v
Reading specs from
/usr/local/lib/gcc-lib/i686-pc-linux-gnulibc1/egcs-2.91.66/specs
gcc version egcs-2.91.66 19990314 (egcs-1.1.2 release)
$ uname -a
Linux gams 2.0.32 #22 Mon Jan 5 22:42:45 MSK 1998 i686 unknown
$ g++ bug.c
$ a.out
CDDD
This is incorrect result. There is extra call of the destructor. Other
compilers produce correct output:
CDD
With best wishes,
Alexander.