MyContainer a = ...;
a.myDeallocate();
a[0] = 3; // This will crash
Given a C++ code snippet that looks like the above one, I would like to make the C++ compiler (either g++ or clang++) raise a warning saying that a
must not be used after its deallocation, possibly by inserting a custom code:
MyContainer a = ...;
a.myDeallocate();
__should_not_use__(a); // If I put this code
a[0] = 3; // The compiler will raise a warning at this point, hopefully.
Is there a way to do this?