3 ms·
If you comment out the delete[] line, it returns the same output. Does that mean leaking memory is undefined behaviour?
by londons_explore 4y ago
If you comment out the delete[] line, it returns the same output. Does that mean leaking memory is undefined behaviour?
- pjmlp 4y agoLeaking memory is always undefined behaviour regardless of the language when talking about manual memory management. What guarantees can you assure about the state of the application? In any case, in this specific example for x64 it doesn't matter, because new gets optimized away. However, if that optimization isn't done, e.g. AVR backend, then nasal daemons will be summoned.