Re:Modern C [pdf]
by nurettin on Monday November 28, 2016 @10:47AM
(#13056120)
The main argument against goto comes from standard C++ side because there are so many edge cases where goto and longjmp will cause your exceptions and end-of-life semantics to go awry.
[ Parent
| on HN ]
If I remember correctly, C++ flat out bans all uses of goto that could affect constructors and destructors. For example, something like this won't compile:
int main() {
goto g;
std::string s;
g: return 0;
}
while this will compile, but destructor is guaranteed to be called: int main() {
{
std::string s;
goto g;
return 1;
}
g: return 0;
}
Now, longjmp is another matter. That thing is basically verboten in any sane C++ environment (and consequently, C libraries that use it across API boundary are very painful to use from C++; R hosting API is a great example of that).