goto
on it's own is:
- Basically useless when RAII is involved (the one legitimate use for it is error-cleanup, and also manual jump tables, which needs computed goto anyways)
- A huge footgun, especially wrt. destructors and partially-initialized values.
Fun fact, C++ disallows using goto
to enter the scope of any local variable, except one initialized by trivial default-init (like int i;
, IE. uninitialized value). goto
in Rust would run into the exact same problem, except rust doesn't have trivial default-init. So goto could only be used in rust to exit the scope of local variables (which triggers drop-glue, if any). Initness checking arround goto also sounds like a fun nightmare.