Explicit destructor call unrecognized

Josh Stern jstern@citilink.com
Wed Aug 26 11:03:00 GMT 1998


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




More information about the Gcc-bugs mailing list