I encountered the same problem.

You do not need to call delete.
As soon as the scope of x ends, ~X() is called.