# V749. Destructor of the object will be invoked a second time after leaving the object's scope.

The analyzer detected an error that has to do with calling a destructor for the second time. When an object is created on the stack, the destructor will be called when the object leaves the scope. The analyzer detected a direct call to the destructor for this object.

Consider the following example:

    void func(){
      X a;
      a.~X();
      foo();
    }

In this code, the destructor for the 'a' object is called directly. But when the 'func' function finished, the destructor for 'a' will be called once again.

To fix this error, we need to remove incorrect code or adjust the code according to the memory management model used.

Correct code:

    void func(){
      X a;
      foo();
    }

This diagnostic is classified as:

CWE-675 CERT-MEM53-CPP

You can look at examples of errors detected by the V749 diagnostic.