Detecting misusage of delete[] vs. delete at compile time
https://softwareengineering.stackexchange.com/questions/186968
-
05-11-2019 - |
Question
I'd like to know if it's possible to detect the delete
error commented below at compile time? Especially, I'd like to hear about g++ compiler.
ClassTypeA *abc_ptr = new ClassTypeA[100];
abc_ptr[10].data_ = 1;
delete abc_ptr; // error, should be delete []
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with softwareengineering.stackexchange