Get the latest tech news

Problems with C++ exceptions


About 23 minutes into his talk about Safe C++ [1], Bjarne shows a slide with this code: void f(const char* p) // unsafe, naive use { FILE *f = fopen(p, "r"); // acquire // use f fclose(f); // release } He shows this code to demonstrate how easy it is to miss resource cleanup. Any code that exits the function inside // use f that doesn’t also call fclose results in a leak.

None

Get the Android app

Or read this on Hacker News

Read more on:

Photo of freaking language

freaking language

Photo of Bjarne

Bjarne