This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Explicit destructor call unrecognized



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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]