This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Explicit destructor call unrecognized
- To: egcs-bugs at cygnus dot com
- Subject: Explicit destructor call unrecognized
- From: Josh Stern <jstern at citilink dot com>
- Date: Wed, 26 Aug 1998 13:00:51 -0500 (CDT)
- Posted-Date: Wed, 26 Aug 1998 13:00:51 -0500 (CDT)
The egcs 08-24 snapshot doesn't allow the
explicit destructor call in the following code
snippet. I think it is legal C++ (it's definitely
useful and has worked for me on other compilers).
#include <strings.h>
class Simple {
int* data;
int mySz;
public:
Simple() : data(0), mySz(0) {}
Simple(int sz) : mySz(sz) { data = new int[sz]; }
~Simple() {
if (data) delete [] data;
data = 0;
mySz = 0;
}
Simple& operator=(const Simple& o) {
if (this != &o) {
if (!o.data) {
~*this;
}
else {
mySz = o.mySz;
data = new int[mySz];
memcpy(data,o.data,sizeof(int)*mySz);
}
}
return *this;
}
};
The error msg given is:
g++ -c -g -O2 destroy.cc
destroy.cc: In method `class Simple & Simple::operator =(const class Simple &)':
destroy.cc:18: no match for `~Simple &'
- Josh
jstern@citilink.com