When I `throw` something, where is it stored in memory?

Yes, the answer is compiler-dependent. A quick experiment with my compiler (g++ 4.4.3) reveals that its runtime library first tries to malloc memory for the exception and, failing that, attempts to allocate space within a process-wide “emergency buffer” that lives on the data segment. If that doesn’t work out, it calls std::terminate(). It would appear …

Read more