What happens when you deallocate a pointer twice or more in C++?

flopex picture flopex · Apr 30, 2010 · Viewed 10.6k times · Source
int main() {
    Employee *e = new Employee();

    delete e;
    delete e;
    ...
    delete e;
    return 0;
}

Answer

CB Bailey picture CB Bailey · Apr 30, 2010

You get undefined behaviour if you try to delete an object through a pointer more than once.

This means that pretty much anything can happen from 'appearing to work' to 'crashing' or something completely random.