Is there a cost to try catch blocks?

14 gsky 2 7/14/2025, 6:49:12 PM brandewinder.com ↗

Comments (2)

stargrazer · 13m ago
Took a few mind shifts to get around what the commenter said vs what exists beyond the link.

The link actually goes to an article with some code snippets which aren't c++. Going to the repository, seems to be .net/c#/f#.

So... for the c++ readers, this isn't c++ related :-)

slowcache · 2h ago
I didn't think that this was much of a thing that needed to be investigated. Adding additional processing into your code will make it slow down.

On a related note, I had a consultant come into my work one time to the teach us some pragmatic things in C++. One of the lessons was that that gcc will not attempt to reorder the code within a try block to optimize it. This could be leading to some very minute slowdown in a C++ app in addition to the overhead associated with try/catch as a whole