#include <iostream>
using namespace std;

struct Foo
{
	Foo(bool should_throw) {
		if(should_throw)
			throw std::logic_error("Constructor failed");
		cout << "Constructed at " << this << endl;
	}
	~Foo() {
		cout << "Destroyed at " << this << endl;
	}
};

void double_free_anyway()
{
	Foo f(false);
	f.~Foo();
	new (&f) Foo(true);
}

int main() {
	try {
		double_free_anyway();
	} catch(std::logic_error& e) {
		cout << "Error: " << e.what();
	}
}