4 ms·
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-li
by nurettin 10y ago
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.
- int_19h 10y agoIf 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).