When, if ever, can delete and free be used interchangeably in C++?
My concern is as follows: Say there is an incorrect mixup in the use of malloc/free and new/delete (not to mention new[]/delete[]). However delete and free doing the same thing fortuitously so this goes uncaught in testing. Later this may lead to a crash in production.
How can I enforce some kind of check to prevent this? Can I be warned if the two are mixed up? If not at compile time, perhaps some code instrumentation at run time? How would I approach this?
Edit: Intention of this question is to find ways to AVOID inadvertent mixup in the usages.