Hi,
I'm trying to throw an exception without a memory leak happens.
Googling I found this FAQ:
https://isocpp.org/wiki/faq/exceptio...not-exceptions
where I read: "Throwing an exception will not cure memory corruption and may lead to further corruption of important user data."
Does it mean that throwing without catching always cause memory leakage? Since the exception object resides on the space managed by compilers does it depend on the compiler?
Code:Code:#include <iostream> #include <stdexcept> void exercise() { std::exception ex; throw ex; // memory leak } int main() { exercise(); try { } catch(...) { return EXIT_SUCCESS; } }
Thanks for any answer, best regards