Re:If goto statements are bad why does linux src have more t...
by wcummings on Tuesday December 16, 2014 @09:55PM
(#8760855)
And C doesn't have exceptions, which otherwise would cover a lot of where goto's are used.
[ Parent
| on HN ]
Re:If goto statements are bad why does linux src have more t...
by shortsightedsid on Tuesday December 16, 2014 @10:27PM
(#8760930)
There is a difference though. Exceptions can result in Stack Unwinding which is costly. Gotos are a jump which costs literally nothing.
Re:If goto statements are bad why does linux src have more t...
by asveikau on Tuesday December 16, 2014 @11:36PM
(#8761095)
In practice you will do the same thing as unwinding the stack. You'll jump to the end of a function where you'll likely free some heap buffers on your way out and you'll return error status to the caller. What will likely happen next is the caller will bubble up the error: free buffers and report error status to their caller. It works out to pretty much the same thing as a modern C++ code base using RAII, just more manual.