When I am writing a demo string class, in the copy assignment function, I try to clear itself through 'delete this' before copy.But it failed.
    Str &operator=(const Str &s) {
        if (this != &s) {  // self-assignment check
            //delete this; //cannot run as I imagine
            this->~Str();  
            _size = s._size;
            _str = new char[_size + 1];
            memcpy(_str, s._str, _size + 1);
        }
        return *this;
    }
    ~Str() {
        _size = 0;
        delete[] _str;
    }
the linux told me
double free or corruption (out) Aborted (core dumped)
 
     
    