I think I am clear on the difference between delete and delete []. The question I am asking here is: sometimes I do have typo and use the wrong one. Then it may or may not crash and normally ends up with hours of debugging.
I wish gcc can detect and give warning on possible misusage on a few simplest cases.
I still have to use “new float[size]” from time to time because of legacy functions that I need to call, so I am more interested in find an error checking tool to catch part of these mistakes.
Use valgrind.
No, you don’t. If a legacy function wants a pointer to the first element of an array of floats, do this:
Don’t do this: