2 ms·
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:
by int_19h 10y ago
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).