It gets tiring constantly hearing this. We discussed it in depth 18 days ago [0]. I'm going to copy and paste something I said then, as it's relevant to your post:
> Also, a minor rant here: Dijkstra's "Go To Statement Considered Harmful" is often mentioned, sometime wordlessly, when goto is brought up, but it seems many of those people misunderstood what was actually being argued. Although he mentions being "convinced that the go to statement should be abolished from all 'higher level' programming languages," his main gripe was that the "unbridled use of the go to statement has an immediate consequence that it becomes terribly hard to find a meaningful set of coordinates in which to describe the process progress." He felt it was "as it stands is just too primitive; it is too much an invitation to make a mess of one's program." So, as others have pointed out already, his main issue was with goto being used in a way that resulted in unstructured, hard to understand programs.
[0] https://news.ycombinator.com/item?id=7191201
Edit: The original paper [1] is so short, it might as well be required reading before people bring up goto near any mention of "considered harmful".
[1] http://www.u.arizona.edu/~rubinson/copyright_violations/Go_T...
Replace the "goto" with "Throw", "break", or "return", or any other construct, and you'd come up with the same problem.
goto cleanup;
/* ... */
cleanup: foo();
... is perfectly idiomatic C. It was the brace style that was the real stinker there.Thankfully he's got the whole section on his site. http://www.stevemcconnell.com/ccgoto.htm
Most of the reason for this is the lack of higher level language constructs (e.g. `finally`). Keeping goto around for cleanup reminds of me of performing demolition with a nuclear bomb.
Personally, I'm not sold that this is enough to argue for the removal of goto. I don't think goto-cleanup is the only sane use case of goto.
C++ should focus on RAII destructors, such as std::lock_guard. I can't think of a legitimate time to use "goto" in C++, unless you were forced to emulate C for some reason.
So a goto is the only thing that can solve this problem.